重定向到另一个端口获取ProxyPass | ProxyPassMatch在位置中定义时不能有路径

时间:2017-04-16 21:32:44

标签: apache ubuntu

我试图将请求重定向到另一个端口,但我收到此错误:

ProxyPass|ProxyPassMatch can not have a path when defined in a location.

这是我的虚拟主机重定向:

<VirtualHost *:80>
        ServerName sub.domain.com.br
        DocumentRoot /var/www/html/xxx
        ServerAlias www.sub.domain.com.br
        Options -Indexes

        ProxyRequests On
        ProxyPreserveHost On

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

        <Location />
                ProxyPass /route/ www.sub.domain.com.br:31311/
                ProxyPassReverse /route/ www.sub.domain.com.br:31311/
        </Location>

        ErrorLog ${APACHE_LOG_DIR}/bot_error.log
        CustomLog ${APACHE_LOG_DIR}/bot_access.log combined


</VirtualHost>

1 个答案:

答案 0 :(得分:0)

嵌套在ProxyPass部分中的ProxyPassReverse<location>子句必须省略第一个参数。这也有一定道理 - 代理&#34;伪位置&#34;必须在<location XXX>级别定义。

所以,对你的示例配置。考虑对它进行改动:

<VirtualHost *:80>
    ServerName sub.domain.com.br
    DocumentRoot /var/www/html/xxx
    ServerAlias www.sub.domain.com.br
    Options -Indexes

    ProxyRequests On
    ProxyPreserveHost On

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

    <Location /route/>                                 # <==
        ProxyPass www.sub.domain.com.br:31311/         # <==
        ProxyPassReverse www.sub.domain.com.br:31311/  # <==
    </Location>

    ErrorLog ${APACHE_LOG_DIR}/bot_error.log
    CustomLog ${APACHE_LOG_DIR}/bot_access.log combined
</VirtualHost>