如何在托管网站的服务器上使用反向代理?

如何在托管网站的服务器上使用反向代理?

我有一台托管网站的服务器,我正在尝试将其用作反向代理服务器。目的是混淆应用程序的 URL,使其http://www.acme.bar.com:8760/Application至 loremipsum.bar.com。

我有一个 loremipsum.bar.com 的别名,指向反向代理/Web 主机,具有以下虚拟主机配置:

<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 并且超时。

答案1

尝试使用类似 Fiddler 的工具(或启用了请求持久性的浏览器开发工具网络检查器)来观察发送的重定向导致重定向循环。您也可以尝试在代理 URL 末尾添加斜线,以防万一 - 这就是我的设置方式以及示例http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse有。

相关内容