Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a website setup and want to be able to access the same site from two different ports. Does anybody know how I would do this?
For example, I want to be able to access exactly the same at http://example.com:5678 as I can at http://example.com:80. I had tried fiddeling with virtualHosts in my httpd.conf from what I read on forums and the docs but couldn't figure it out - any ideas? Also, how would I be able to make it work for http://domain1.com:80 shows the same as http://domain2.com:5678? (for both where domain1 and domain2 are hosted on same server)

Does WHM/cPanel support this (other than domain parking)? If not, how would I change my apache to do this?

Thanks

Sam

Updated

I am not sure that you understood. I have a virtualHost set up and want that to be accessible from two different ports, showing exactly the same. Here is my virtual host currently.

<VirtualHost 184.107.24.1:80>
    ServerName example.co.uk
    ServerAlias www.example.co.uk
    DocumentRoot /home/example/public_html
    ServerAdmin webmaster@example.co.uk
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/example.co.uk combined
    CustomLog /usr/local/apache/domlogs/example.co.uk-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User example # Needed for Cpanel::ApacheConf
    UserDir enabled example
    <IfModule mod_suphp.c>
        suPHP_UserGroup example example
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup example example
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RUidGid example example
    </IfModule>
    ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/


    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/example/example.co.uk/*.conf"

</VirtualHost>
share|improve this question

2 Answers 2

up vote 0 down vote accepted

You can specify multiple binding addresses and ports in VirtualHost.

Change

<VirtualHost 184.107.24.1:80>

To

<VirtualHost 184.107.24.1:80 184.107.24.1:5678>

You will also need to specify the port outside of the VHost, so your config might look something like this:

Listen 80
NameVirtualHost 184.107.24.1:80

Listen 5678   
NameVirtualHost 184.107.24.1:5678

<VirtualHost 184.107.24.1:80 184.107.24.1:5678>
    ServerName example.co.uk
    ServerAlias www.example.co.uk
    DocumentRoot /home/example/public_html
    ServerAdmin webmaster@example.co.uk
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/example.co.uk combined
    CustomLog /usr/local/apache/domlogs/example.co.uk-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User example # Needed for Cpanel::ApacheConf
    UserDir enabled example
    <IfModule mod_suphp.c>
        suPHP_UserGroup example example
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup example example
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RUidGid example example
    </IfModule>
    ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/


    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/example/example.co.uk/*.conf"

</VirtualHost>

Update for your question:

If you want domain1.com:80 and domain2.com:5678 to display the same content, but do not want domain1.com:80 and domain2.com:800 to be the same...then you will need to seperate the vhosts.

<VirtualHost 184.107.24.1:80>
ServerName domain1.com
ServerAlias *.domain1.com
</VirtualHost>

<VirtualHost 184.107.24.1:5678>
ServerName domain2.com
ServerAlias *.domain2.com
</VirtualHost>
share|improve this answer
    
is what you are saying then that I don't need to use: ProxyRequest Off; ProxyPass / http://example.co.uk:5678/; ProxyPassReverse / http://example.co.uk:5678/; ? –  Sam Heather Apr 12 '13 at 8:29
    
No, you don't need them from what I can tell from your question. –  David Houde Apr 12 '13 at 8:31
    
Thanks - that seems to work. As you can see from the example, it says do not edit because it is automatically generated by WHM/cPanel. Any idea on how I would add this stuff in more permanently so cPanel doesn't get rid of it? Thanks. –  Sam Heather Apr 12 '13 at 10:44
    
I don't have much experience with that, sorry. I don't know that you will get much of a response here either. I would suggest posting a new question now that your config is okay, tailored specifically towards cPanel. –  David Houde Apr 12 '13 at 10:46

If it's the same domain name just add:

Listen 5678

In the same location you have

Listen 80
share|improve this answer
    
thanks, but it says I can't put that into my VirtualHost. See above update to post. –  Sam Heather Apr 12 '13 at 7:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.