我有一个托管网站的服务器,我试图将其另外用作反向代理服务器。目的是将应用程序的 url 从http://www.acme.bar.com:8760/Application混淆到 loremipsum.bar.com。
我有一个 loremipsum.bar.com 的别名,指向反向代理/网络主机,具有以下虚拟主机配置:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/public
<Directory /var/www/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
order allow,deny
allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:80>
ProxyPass / http://www.acme.bar.com:8760/Application
ProxyPassReverse / http://www.acme.bar.com:8760/Application
ServerName loremipsum.bar.com
</VirtualHost>
不幸的是,现在访问 loremipsum.bar.com 会出现 ERR_TOO_MANY_REDIRECTS 并超时。
尝试使用 Fiddler(或打开请求持久化的浏览器的开发工具网络检查器)来观察正在发送的重定向导致重定向循环。您也可以尝试在代理 URL 的末尾添加一个斜杠,以防万一 - 这就是我设置它的方式以及http://httpd.apache.org/docs/2.2/mod上的示例/mod_proxy.html#proxypassreverse有它。