首页 文章

来自加载的网站的反向代理请求未被代理

提问于
浏览
0

我有这样的反向代理设置 .

http://example.com/3rdpartywebsite/ - > http://internal.addr/3rdpartywebsite/

因此,对example.com的请求被反向代理到内部网络上的网站 .

问题是3rdpartywebsite是jquery,并且一旦在浏览器中加载请求就会将请求返回给主机 . 这些请求(来自加载的应用程序)未被重定向到http://example.com/3rdpartyProxy/,而是转到http://example.com/

这似乎与标准getHttpObject()返回的内容有关 . 它不知道url的"3rdpartyProxy"部分,只是返回http://example.com/

以下是来自apache的反向代理配置的内容:

ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
        Order allow,deny
        Allow from all
</Proxy>
ProxyPass /3rdpartywebsite/ http://internal.addr/
ProxyPassReverse /3rdpartywebsite/ http://internal.addr/

任何帮助将不胜感激,我甚至不确定从哪里开始看这里 . 是反向代理的问题,还是我应该查看网站本身的问题?

1 回答

  • 0

    我会回答我自己的问题!好极了 .

    我最终使用它的方法是使用以下站点配置 . 我使用反向代理,然后重写 . 在我的情况下,重写很简单,只需重写一次对第三方服务的cgi-bin调用即可 .

    第三方服务工作的正确方式是使用相对路径,但由于使用了绝对路径,因此我被迫进入此解决方案 .

    重要的是要注意,如果重写引擎在反向代理之前生效,则这将不起作用 . 你最终会得到一个死链接 .

    虚拟主机配置:

    <VirtualHost *:80>
        ServerAdmin     webmaster@host.net<br>
        ServerName      host.net
        ServerAlias     www.host.net
        DocumentRoot    /var/www/
        DirectoryIndex  index.php index.html
    
        ProxyRequests Off
        ProxyPreserveHost On
        <Proxy *>
                Order allow,deny
                Allow from all
        </Proxy>
        ProxyPass /3rdPartyWebsite/ http://192.168.0.1/
        ProxyPassReverse /3rdPartyWebsite/ http://192.168.0.1/
    
    
        #RewriteLog /home/rfmondial/rewrite.log
        #RewriteLogLevel 9
    
        <FilesMatch \.php$>
                SetHandler application/x-httpd-php
        </FilesMatch>
    
        <Directory />
                AllowOverride none
                order deny,allow
                allow from all
        </Directory>
    
        <Directory /var/www>
                Options FollowSymLinks
                allow from all
    
                RewriteEngine On
                #http://host/ --> http://domain/3rdPartyWebsite/ (default ROOT in Tomcat) a
                RewriteCond !%{REQUEST_URI} !nt-gui/
                RewriteRule ^(cgi-bin.*)$ 3rdPartyWebsite/$1 [L]
        </Directory>
    </VirtualHost>
    

相关问题