简体   繁体   English

从virtualhost proxypass中排除别名

[英]Exclude an alias from virtualhost proxypass

I've following virtual host configuration. 我正在关注虚拟主机配置。 The desired result is: 期望的结果是:

  1. If someone requests http://test.myserver.com/myapp , apache serves him from /var/www/myapp 如果有人请求http://test.myserver.com/myapp,apache会从/ var / www / myapp为他提供服务
  2. And if http://test.myserver.com/ is requested, apache redirects it to port 8069. 如果请求http://test.myserver.com/,apache会将其重定向到端口8069。

2nd is working but 1st is not. 第二个工作,但第一个不工作。 Can someone help please! 请有人帮忙!

<VirtualHost *:80>
        ServerName test.myserver.com

        Alias /myapp /var/www/myapp
        <Directory /var/www/myapp>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>

        ProxyPass / http://localhost:8069/
        ProxyPassReverse / http://localhost:8069/

</VirtualHost>

This is how I was able to achive the desired outcome. 这就是我能够达到预期结果的方式。 Following is the working configuration where ProxyPassMatch ^/myapp ! 以下是ProxyPassMatch ^/myapp !的工作配置ProxyPassMatch ^/myapp ! did the trick and except the (server-address)/myapp, all the requests are being proxying to the other server which is open-erp running at port 8069: 除了(服务器地址)/ myapp之外,所有的请求都是代理到另一个服务器,它是在端口8069上运行的open-erp:

<VirtualHost *:80>
        ServerName test.myserver.com

        Alias /myapp /var/www/myapp
        <Directory /var/www/myapp>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>

        ProxyPassMatch ^/myapp !
        ProxyPass / http://localhost:8069/
        ProxyPassReverse / http://localhost:8069/


  CustomLog /var/log/apache2/access.log common
  ErrorLog /var/log/apache2/error.log

</VirtualHost>

Instead of using: ProxyPassMatch ^/myapp ! 而不是使用: ProxyPassMatch ^/myapp ! you could have simply added another ProxyPass directive before the one defining /, like this: 您可以在定义/之前添加另一个ProxyPass指令,如下所示:

ProxyPass /myapp !
ProxyPass / http://localhost:8069/

Since ProxyPass respects precedence (the first match will be processed), it will correctly redirect to the directory instead of proxying. 由于ProxyPass尊重优先级(将处理第一个匹配),因此它将正确地重定向到目录而不是代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM