Change the default port of ispCP



The ports are logical places that are used by the protocols, such as TCP and UDP for communicate with the differents services, such as http, that provide the servers.

The port ranging from the numbers 0 to 65536 and are divided into three ranges:

Well Known Ports (0 through 1023) Registered Ports (1024 through 49151) Dynamic and/or Private Ports (49152 through 65535)

The international authority that regule the official ports assignement is IANA. http://www.iana.org/assignments/port-numbers

This Howto explains how you can change the 80 default port of ispCP 1.0.0 RC3 for another.

When choosing a port, check that the number isn't used by any other service of the server.

In this howto we will use 348

1. After installation, if you have selected admin.domain.tld as ispCP domain, create a new user domain with domain.tld ( necessary for the logs records and also can be used for content with the standart 80 port)

2. Open /etc/apache2/sites-available/00_master.conf and change:

<VirtualHost XXX.XXX.XXX.XXX:80>

    ServerAdmin     user@my_domain.tld
    DocumentRoot    /var/www/ispcp/gui

    ServerName      admin.domain.tld
    ErrorLog        /var/log/apache2/users/admin.domain.tld-error.log
    TransferLog     /var/log/apache2/users/admin.domain.tld-access.log

    CustomLog       /var/log/apache2/admin.domain.tld-traf.log traff
    CustomLog       /var/log/apache2/admin.domain.tld-combined.log

to

<VirtualHost XXX.XXX.XXX.XXX:348>

    ServerAdmin     user@my_domain.tld
    DocumentRoot    /var/www/ispcp/gui

    ServerName      domain.tld:348
    ErrorLog        /var/log/apache2/users/domain.tld-error.log
    TransferLog     /var/log/apache2/users/domain.tld-access.log

    CustomLog       /var/log/apache2/domain.tld-traf.log traff
    CustomLog       /var/log/apache2/domain.tld-combined.log

3. In /etc/apache2/ports.conf add line:

Listen 348

4. In /etc/ispcp/ispcp.conf change:

BASE_SERVER_VHOST = admin.domain.tld

to

BASE_SERVER_VHOST = domain.tld:348

5. In /var/www/ispcp/gui/domain_default_page/index.html search and change:

http://{BASE_SERVER_VHOST}

to

http://{DOMAIN_NAME}:348

6. In /var/www/ispcp/gui/include/login.php in line 188 change:

    if ($checkReferer) {
        if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) {

            $info = parse_url($_SERVER['HTTP_REFERER']);
            if (isset($info['host']) && !empty($info['host'])) {
                if ($info['host'] != $_SERVER['HTTP_HOST'] || $info['host'] != $_SERVER['SERVER_NAME']) {
                    set_page_message(tr('Request from foreign host was blocked!'));
                    redirect_to_level_page();
                }
            }
        }
    }

to

     if ($checkReferer) {
         if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) {

            $info = parse_url($_SERVER['HTTP_REFERER']);
            if (isset($info['host']) && !empty($info['host'])) {
                if ($_SERVER['SERVER_PORT']!=80) {                
                    if ($info['host'].':'.$_SERVER['SERVER_PORT'] != $_SERVER['HTTP_HOST']|| $info['host'].':'.$_SERVER['SERVER_PORT'] != $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']) {
	                    set_page_message(tr('Request from foreign host was blocked!'));
	                    redirect_to_level_page();
                    }
                }else{
                    if ($info['host'] != $_SERVER['HTTP_HOST'] || $info['host'] != $_SERVER['SERVER_NAME']) {
	                    set_page_message(tr('Request from foreign host was blocked!'));
	                    redirect_to_level_page();
                    }
                }
             }    
         }
     }

7. Restart apache.

Now you can login with any virtual domain hosted in your server with the URL http://virtual_domain:348

Be happy.