【问题标题】:How to redirect different URLs to different ports on the same domain?如何将不同的 URL 重定向到同一域上的不同端口?
【发布时间】:2015-03-15 20:58:52
【问题描述】:

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

我知道这类似于Redirecting from port 80 to different ports based on URL。我想按照 abhi-devireddy 的建议实施反向代理解决方案。我尝试了以下反向代理。所有请求都转发到端口 8069,包括http://example.com/wordpress/。当浏览器指向http://example.com/wordpress时,Odoo 报错 404 page not found

<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>

【问题讨论】:

    标签: redirect apache2 port openerp reverse-proxy


    【解决方案1】:

    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>
    

    【讨论】:

      猜你喜欢
      • 2020-01-20
      • 2014-04-06
      • 2016-11-13
      • 1970-01-01
      • 2014-08-05
      • 2017-11-30
      • 2021-03-18
      • 2013-10-01
      • 1970-01-01
      相关资源
      最近更新 更多