apache - 是否可以在 ProxyPass/ProxyPassReverse 中使用相对路径?

标签 apache proxy apache2 reverse-proxy

例如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/

相关文章:

ubuntu - apache 重启失败

apache - XAMPP 访问被禁止 [ubuntu]

proxy - 当服务器在 Varnish 反向代理之后(反过来又在负载均衡器之后)时,在apache日志中获取客户端IP地址

c# - 通过代理读取外部 XML

maven - Android Studio连接被拒绝

Apache2 无法启动,ulimit 错误?

php - PHP 有自己的 Web 服务器吗?

php - 为 Apache 设置 Windows 身份验证

php - Apache 和/或 PHP 超时 - 难住了。

Apache : Using SSL with j_security_check 背后的 Tomcat