0

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 [email protected]
    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>
0

2 Answers 2

1

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 [email protected]
    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>
4
  • 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/; ? Apr 12, 2013 at 8:29
  • No, you don't need them from what I can tell from your question. Apr 12, 2013 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. Apr 12, 2013 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. Apr 12, 2013 at 10:46
0

If it's the same domain name just add:

Listen 5678

In the same location you have

Listen 80
1
  • thanks, but it says I can't put that into my VirtualHost. See above update to post. Apr 12, 2013 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .