ubuntu apache2 mod_proxy 替换内部 url

发布于 2024-12-29 18:52:16 字数 1099 浏览 4 评论 0原文

我已经按照我在谷歌上找到的所有指南进行了操作,但仍然无法解决这个问题!

我已成功设置 mod_proxy 来拉回内部网站,但该网站向菜单项添加了内部链接,这对外部用户不起作用,因此我尝试将它们从 .int 域重写为 < code>.com 域。

我有以下虚拟主机。

<VirtualHost *:80>
    ServerName shop.itmanx.com

    ProxyRequests Off
    ProxyPreserveHost On
    #ProxyHTMLInterp On     #used to be ProxyHTMLEnable
    #ProxyHTMLExtended On   #will parse all scripts and css files as well [slow if on]

    ProxyPass / http://shop.itmanx.int/
    ProxyPassReverse / http://shop.itmanx.int/
    #ProxyHTMLURLMap / /test/
    ProxyHTMLURLMap (.*)itmanx.int(.*) $1itmanx.com$2 [Rin]

    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

我已确保组件已加载

[Sun Jan 29 14:59:46 2012] [warn] module proxy_module is already loaded, skipping
[Sun Jan 29 14:59:46 2012] [warn] module proxy_http_module is already loaded, skipping
[Sun Jan 29 14:59:46 2012] [warn] module proxy_html_module is already loaded, skipping

,但没有更改链接。那么我错过了什么?

服务器是Ubuntu Server 11.10

I've followed every guide I can find on Google and still cant solve this!

I've managed to set up mod_proxy to pull back an internal website, but the website adds internal links to menu items which wont work for external users, so Im trying to rewrite them from .int domains to .com domains.

I have the following virtual host.

<VirtualHost *:80>
    ServerName shop.itmanx.com

    ProxyRequests Off
    ProxyPreserveHost On
    #ProxyHTMLInterp On     #used to be ProxyHTMLEnable
    #ProxyHTMLExtended On   #will parse all scripts and css files as well [slow if on]

    ProxyPass / http://shop.itmanx.int/
    ProxyPassReverse / http://shop.itmanx.int/
    #ProxyHTMLURLMap / /test/
    ProxyHTMLURLMap (.*)itmanx.int(.*) $1itmanx.com$2 [Rin]

    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

I have made sure the components are loaded

[Sun Jan 29 14:59:46 2012] [warn] module proxy_module is already loaded, skipping
[Sun Jan 29 14:59:46 2012] [warn] module proxy_http_module is already loaded, skipping
[Sun Jan 29 14:59:46 2012] [warn] module proxy_html_module is already loaded, skipping

but no links are altered. So what am i missing?

The server is Ubuntu Server 11.10

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑕疵 2025-01-05 18:52:16

哈扎!!!感谢 Hudson 引用以下内容的人:

因为 hudson 已经压缩了它的输出,所以你不能使用正常的
proxy-html 过滤器修改网址:`

SetOutputFilter proxy-html

您可以使用以下内容:

SetOutputFilter INFLATE;proxy-html;DEFLATE;

因为这一行,现在正在工作

<VirtualHost *:80>
    ServerName shop.itmanx.com
    SetEnv proxy-nokeepalive 1

    ProxyPass / http://shop.itmanx.int/
    ProxyPassReverse / http://shop.itmanx.int/
    ProxyRequests Off

    SetOutputFilter INFLATE;proxy-html;DEFLATE;
    ProxyHTMLURLMap (.*)itmanx.int(.*) $1itmanx.com$2 [R]
</VirtualHost>

Huzzah!!! Thanks to the guys at Hudson who quoted the following:

Because hudson already compress its output, you can not use the normal
proxy-html filter to modify urls:`

SetOutputFilter proxy-html

Instead you can use the following:

SetOutputFilter INFLATE;proxy-html;DEFLATE;

and because of this one line, it's now working

<VirtualHost *:80>
    ServerName shop.itmanx.com
    SetEnv proxy-nokeepalive 1

    ProxyPass / http://shop.itmanx.int/
    ProxyPassReverse / http://shop.itmanx.int/
    ProxyRequests Off

    SetOutputFilter INFLATE;proxy-html;DEFLATE;
    ProxyHTMLURLMap (.*)itmanx.int(.*) $1itmanx.com$2 [R]
</VirtualHost>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文