例如httpd.conf中有如下配置:
ProxyPass app http://somehost:someport/App_1
ProxyPassReverse app http://somehost:someport/App_1
现在我应该使用绝对 url 将请求从“/myapp”转发到“/app”:
<Location /myapp >
ProxyPass http://localhost:8080/app
ProxyPassReverse http://localhost:8080/app
</Location>
是否可以在 ProxyPass/ProxyPassReverse 中使用相对路径?
<Location /myapp >
ProxyPass /app
ProxyPassReverse /app
</Location>
最佳答案
不。
apache docs about ProxyPass说目标必须是一个 URL。如果您尝试放置不是 URL 的内容(例如 /app
),则会出现以下错误:
ProxyPass URL must be absolute!
您应该查看 mod_rewrite反而。它可以在不重定向浏览器的情况下在服务器端重写请求。以您的/myapp ->/app 示例为例,一些简单的规则就足够了:
RewriteRule ^/myapp /app [L]
关于apache - 是否可以在 ProxyPass/ProxyPassReverse 中使用相对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8853077/