我的服务器端位于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/