Newb: Need to understand the fundamentals...

Discussion in 'Installation/Configuration' started by Slowhand, Jun 4, 2009.

  1. Croydon

    Croydon Member Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    There are two separate plugins. One für webmail, one for phpmyadmin.
    Both request an installed version of the corresponding software in /var/www

    i.e. the webmail program has to be reachable through /var/www/webmail and the phpmyadmin through /var/www/phpmyadmin.
    Whether these are symlinks to another location (e.g. /usr/share/squirrelmail or /etc/usr/roundcube) or really installed under /var/www doesn't matter.
     
  2. Slowhand

    Slowhand New Member

    Croydon,

    Ok, that's basically what I thought.

    In that case, why wouldn't it work to create an https folder in /var/www/ and use a variation of the plugin?

    Was my Technique to adapt the plugin correct btw?

    Slowhand
     
  3. Croydon

    Croydon Member Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    Because a https folder (with https support) needs a changed vhost config.
    None of the current plugins does that.
    You would have to write a more complex plugin to support that. Take a look at the apache2 plugin of ispc. It is quite huge.

    I cannot tell you if your adapting was correct because the answer would be "yes" for some usage case and "no" for others.
     
  4. Slowhand

    Slowhand New Member

    Croydon,

    I'm going to leave you alone I promise...

    In that case, what is the best method to serve *any* page behind https when an 's' is added to http://, *server-wide* without upsetting ISPc? Edit a vhost config file? which one?
    I can find:
    /etc/apache2/mods-available/vhost_alias.load
    /etc/apache2/sites-available/ispconfig.vhost
    /etc/apache2/sites-enabled/000-ispconfig.vhost

    I'll figure out *how* to do it after that ;-)

    Slowhand
     
  5. Croydon

    Croydon Member Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    Although i really really don't know what this could be good for...

    You could create a new vhost file in sites-available (e.g. global-ssl.vhost) and symlink it to sites-enabled

    Then you would have to create ssl key and cert files.

    The vhost file content might look like this:
    Code:
    <IfModule mod_ssl.c>
    
    <VirtualHost *:443>
        DocumentRoot /var/www/globalhttps
    
        ServerName example.com
        ServerAlias seconddomain.com thirddomain.com
        ServerAdmin webmaster@example.com
    
        ErrorLog /var/log/apache2/sslerror.log
    
       SSLEngine on
        SSLCertificateFile /path/to/crtfile
        SSLCertificateKeyFile /path/to/keyfile
    
            <Directory /var/www/globalhttps>
            Options FollowSymLinks
            AllowOverride Indexes AuthConfig Limit FileInfo
            Order allow,deny
            Allow from all
        </Directory>
    
       # mod_php enabled
        AddType application/x-httpd-php .php .php3 .php4 .php5
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@example.com"
        php_admin_value upload_tmp_dir /tmp
        php_admin_value session.save_path /tmp
    
    </VirtualHost>
    </IfModule>
    
    
     
  6. Slowhand

    Slowhand New Member

    (Thanks for those instructions. They definitely won't upset ISPc)

    Doesn't it make sense to always serve *any* login behind https?

    If a user can simply add an 's' in the url and be secure, isn't that desirable?

    S
     
  7. Croydon

    Croydon Member Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    Hum... So... I begin to think that you made it all a lot more complicated than necessary...

    Do not change any files, just go to the "sites" tab, edit a website, check the "SSL" checkbox, go to the "SSL" tab and enter your SSL certificate details (or choose to create one at the bottom select box).
    Then wait a minute (for the server to complete) and you can use the website with http and https after that. No separate folders.
     
  8. Slowhand

    Slowhand New Member

    Ha! :) Perfect.

    after that http and https are interchangeable?

    Too easy really... ;-)

    S
     
  9. Slowhand

    Slowhand New Member

    Croydon,

    Trying to create a plugin for a forum...

    If I called this plugin
    Code:
     forum_symlink_plugin
    and did
    Code:
     /usr/local/ispconfig/server/plugins-available/forum_symlink_plugin.inc.php
    
    and
    Code:
    ln -s /usr/local/ispconfig/server/plugins-available/forum_symlink_plugin.inc.php /usr/local/ispconfig/server/plugins-enabled/forum_symlink_plugin.inc.php
    
    using
    Code:
    <?php
    
    /*
    Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
    All rights reserved.
    Modification (c) 2009, Marius Cramer, pixcept KG 
    
    Redistribution and use in source and binary forms, with or without modification,
    are permitted provided that the following conditions are met:
    
        * Redistributions of source code must retain the above copyright notice,
          this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        * Neither the name of ISPConfig nor the names of its contributors
          may be used to endorse or promote products derived from this software without
          specific prior written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    class forum_symlink_plugin {
        
        var $plugin_name = 'forum_symlink_plugin';
        var $class_name = 'forum_symlink_plugin';
        
        var $action;
        
        //* This function is called during ispconfig installation to determine
        //  if a symlink shall be created for this plugin.
        function onInstall() {
            global $conf;
            
            if($conf['services']['web'] == true) {
                return true;
            } else {
                return false;
            }
            
        }
        
            
        /*
             This function is called when the plugin is loaded
        */
        
        function onLoad() {
            global $app;
            
            /*
            Register for the events
            */
            
            $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
            $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
        }
        
        function insert($event_name,$data) {
            global $app, $conf;
            
            $this->action = 'insert';
            // just run the update function
            $this->update($event_name,$data);
        }
        
        function update($event_name,$data) {
            global $app, $conf;
            
            if($this->action != 'insert') $this->action = 'update';
            
            if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
                
                $old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
                $new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
                
                // If the parent_domain_id has been chenged, we will have to update the old site as well.
                if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
                    $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
                    $data["new"] = $tmp;
                    $data["old"] = $tmp;
                    $this->action = 'update';
                    $this->update($event_name,$data);
                }
                
                // This is not a vhost, so we need to update the parent record instead.
                $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
                $data["new"] = $tmp;
                $data["old"] = $tmp;
                $this->action = 'update';
            }
            
            if($data["new"]["document_root"] == '') {
                $app->log("document_root not set",LOGLEVEL_WARN);
                return 0;
            }
            
            $symlink = true;
            if($data["new"]["php"] == "suphp") $symlink = false;
            elseif($data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y") $symlink = false;
            elseif($data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y") $symlink = false;
            
            
            if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
            if($symlink == false) {
                if(is_link($data["new"]["document_root"]."/web/forum")) exec("rm -f ".$data["new"]["document_root"]."/web/forum");
            } else {
                if(!is_link($data["new"]["document_root"]."/web/forum")) exec("ln -s /var/www/phpmyadmin ".$data["new"]["document_root"]."/web/forum");
                else exec("ln -sf /var/www/phpmyadmin ".$data["new"]["document_root"]."/web/forum");
            }
        }
        
    
    } // end class
    
    ?> 
    
    Would it work?

    Slowhand
     
  10. Croydon

    Croydon Member Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    It would work I think but it would create a symlink to /var/www/phpmyadmin (you didn't change that).

    And I don't think that doing this with a forum is a good idea since forums often need a fix url (http://www.example.com/forum/) and don't work on multiple hosts. But you could give it a try.
    Of course you would have to install the forum in /var/www/forum and change the symlink in the plugin.
     
  11. Slowhand

    Slowhand New Member

    Croydon,

    Sorry... like this then
    Code:
    <?php
    
    /*
    Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
    All rights reserved.
    Modification (c) 2009, Marius Cramer, pixcept KG 
    
    Redistribution and use in source and binary forms, with or without modification,
    are permitted provided that the following conditions are met:
    
        * Redistributions of source code must retain the above copyright notice,
          this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        * Neither the name of ISPConfig nor the names of its contributors
          may be used to endorse or promote products derived from this software without
          specific prior written permission.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    class forum_symlink_plugin {
        
        var $plugin_name = 'forum_symlink_plugin';
        var $class_name = 'forum_symlink_plugin';
        
        var $action;
        
        //* This function is called during ispconfig installation to determine
        //  if a symlink shall be created for this plugin.
        function onInstall() {
            global $conf;
            
            if($conf['services']['web'] == true) {
                return true;
            } else {
                return false;
            }
            
        }
        
            
        /*
             This function is called when the plugin is loaded
        */
        
        function onLoad() {
            global $app;
            
            /*
            Register for the events
            */
            
            $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
            $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
        }
        
        function insert($event_name,$data) {
            global $app, $conf;
            
            $this->action = 'insert';
            // just run the update function
            $this->update($event_name,$data);
        }
        
        function update($event_name,$data) {
            global $app, $conf;
            
            if($this->action != 'insert') $this->action = 'update';
            
            if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
                
                $old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
                $new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
                
                // If the parent_domain_id has been chenged, we will have to update the old site as well.
                if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
                    $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
                    $data["new"] = $tmp;
                    $data["old"] = $tmp;
                    $this->action = 'update';
                    $this->update($event_name,$data);
                }
                
                // This is not a vhost, so we need to update the parent record instead.
                $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
                $data["new"] = $tmp;
                $data["old"] = $tmp;
                $this->action = 'update';
            }
            
            if($data["new"]["document_root"] == '') {
                $app->log("document_root not set",LOGLEVEL_WARN);
                return 0;
            }
            
            $symlink = true;
            if($data["new"]["php"] == "suphp") $symlink = false;
            elseif($data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y") $symlink = false;
            elseif($data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y") $symlink = false;
            
            
            if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
            if($symlink == false) {
                if(is_link($data["new"]["document_root"]."/web/forum")) exec("rm -f ".$data["new"]["document_root"]."/web/forum");
            } else {
                if(!is_link($data["new"]["document_root"]."/web/forum")) exec("ln -s /var/www/forum ".$data["new"]["document_root"]."/web/forum");
                else exec("ln -sf /var/www/forum ".$data["new"]["document_root"]."/web/forum");
            }
        }
        
    
    } // end class
    
    ?> 
    I don't understand your point about the address...

    What would the resulting address look like? not http://www.example.com/forum/?

    S
     

Share This Page