2012-01-13 50 views
4

例如有在httpd.conf配置如下:是否可以在ProxyPass/ProxyPassReverse中使用相对路径?

ProxyPass app http://somehost:someport/App_1 
ProxyPassReverse app http://somehost:someport/App_1 

现在我应该使用绝对URL转发来自“/ MyApp的”到“/应用程序”的要求:

<Location /myapp > 
    ProxyPass http://localhost:8080/app 
    ProxyPassReverse http://localhost:8080/app 
</Location> 

是否有可能在ProxyPass/ProxyPassReverse中使用相对路径?

<Location /myapp > 
    ProxyPass /app 
    ProxyPassReverse /app 
</Location> 

回答

2

apache docs about ProxyPass说,目标必须是一个URL。如果你试图把东西是不是一个URL(如/app),您会收到以下错误:

ProxyPass URL must be absolute!

你应该看看mod_rewrite代替。它可以重写服务器端的请求而不用重定向浏览器。给你的/ myapp - > /应用程序的例子,这样一些简单的规则就足够了:

RewriteRule ^/myapp /app [L] 
+0

为什么有可能使用平衡器结构? ProxyPass平衡器:// app。或者平衡器:// app - 它是URL? – 2012-01-13 22:28:13

+1

是的,'平衡器:// app'是一个URL。它映射到一堆成员,比如'ajp:// app.domain.com'也是URL。当然,'ftp:// some.host.com/dir'也是一个URL,但它在ProxyPass中不受支持。 – 2012-01-14 00:37:25

+0

ProxyPassMatch怎么样? – 2017-06-20 11:44:57

相关问题