如何将不同的 URL 重定向到同一域中的不同端口?

How to redirect different URLs to different ports on the same domain?

我在端口 8069 上安装了 odoo 运行ning,我想在同一域的端口 80 上安装 wordpress 运行。我想将 example.com* 重定向到 8069 端口,example.com/wordpress* 我想重定向到 80 端口。

我知道这类似于 。我想按照 abhi-devireddy 的建议实施反向代理解决方案。我尝试了以下反向代理。所有请求都转发到端口 8069,包括 http://example.com/wordpress/。当浏览器指向 http://example.com/wordpress

时,Odoo 报告错误 404 找不到页面
<VirtualHost *:80>

        ServerName odoo
        ErrorLog /var/log/odoo/odoo-error.log
        CustomLog /var/log/odoo/odoo-access.log combined

        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>

        ProxyRequests Off
        ProxyPreserveHost On

        ProxyPass / http://example.com:8069/
        ProxyPassReverse / http://example.com:8069/

        ProxyPass http://example.com/wordpress/ http://example.com:80/wordpress
        ProxyPassReverse http://example.com/wordpress/ http://example.com:80/wordpress


        ProxyVia On
        LogLevel warn

</VirtualHost>

ProxyPass ! 从反向代理中排除 URL http://example.com:80/wordpress。这允许除 http://example.com:80/wordpress 之外的所有内容都映射到端口 8069,同时让 http://example.com:80/wordpress 通过端口 80:

<VirtualHost *:80>

        ServerName odoo
        ErrorLog /var/log/odoo/odoo-error.log
        CustomLog /var/log/odoo/odoo-access.log combined

        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>

        ProxyRequests Off
        ProxyPass /wordpress !
        ProxyPass / http://example.com:8069/
        ProxyPassReverse / http://example.com:8069/

        Alias /wordpress /var/lib/wordpress/

        # ProxyVia On
        LogLevel warn

</VirtualHost>