编程Apache VirtualHosts以使站点可从两个端口访问

时间:2013-04-12 07:53:26

标签: apache http proxy config virtualhost

我的服务器端位于http://example.co.uk,可通过网络浏览器(或通过正常的http请求)访问http://example.co.uk。但是,为了让我的应用程序能够访问服务器端,我希望它能够在端口5678上访问完全相同的内容。所以我尝试在我的apache配置中的virtualHosts中编程:

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

(这就是我原来的)。我尝试添加Listen 5678并添加3行代理请求:

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

1 个答案:

答案 0 :(得分:1)

将您的ports.conf文件编辑为:

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

更改VirtualHost定义
<VirtualHost 184.107.24.1:80 184.107.24.1:5678>