Sam Heather
Sam Heather

Reputation: 1503

Programming Apache VirtualHosts to make site accessible from two ports

I have my server side at http://example.co.uk, which is accessible in a web browser (or via a normal http request) to http://example.co.uk. However, for my app to be able to access the server side, I'd like it to be able to access exactly the same content on port 5678. So I tried to program this in virtualHosts in my apache config:

<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>

(that is what I had originally). I have tried adding Listen 5678 and adding 3 lines about a proxy request:

ProxyRequest Off
ProxyPass / http://example.co.uk:5678/
ProxyPassReverse / http://example.co.uk:5678/

Upvotes: 0

Views: 333

Answers (1)

Rodolphe
Rodolphe

Reputation: 858

Edit your ports.conf file as :

NameVirtualHost *:80
Listen 80
NameVirtualHost *:5678
Listen 5678

Change the VirtualHost definition by

<VirtualHost 184.107.24.1:80 184.107.24.1:5678>

Upvotes: 1

Related Questions