Apache重写多个REQUEST_URI

时间:2015-09-30 14:48:47

标签: apache owncloud plex

我正在努力让Plex和OwnCloud与Apache合作。我目前正确设置了Plex,来自http://server.com/的请求被重写并代理到localhost:32400/web/。我通过以下配置实现了这一目标:

<VirtualHost *:80>
   ServerName mattstv.xyz
   <Proxy *>
      Order deny,allow
      Allow from all
   </Proxy>

   RewriteEngine On

   RewriteCond %{REQUEST_URI} ^/owncloud$
   RewriteCond %{HTTP:X-Plex-Device} ^$
   RewriteRule ^/$ /web/$1 [P,R]

   ProxyRequests Off
   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:32400/
   ProxyPassReverse / http://127.0.0.1:32400/
</VirtualHost>

我希望保留此设置,因为当他们在浏览器中看到32400/web/index.html时,我的家人不会感到困惑。

我已将OwnCloud添加到服务器,并尝试让http://server.com/owncloud无法代理或重写。我有一条规则来检查/owncloud中的REQUEST_URI,但它似乎没有效果。

转到http://server.com/owncloud

时收到以下回复

<MediaContainer size="0" content="plugins"></MediaContainer>

看起来它正在拉动主页面,但没有一个脚本根据调试器进行解析:

chrome debugger

当我完全禁用虚拟主机时,OwnCloud URL正常工作。

从阅读Apache文档我相信如果重写条件失败,代理将不会发生?

1 个答案:

答案 0 :(得分:0)

使用Plex,OwnCloud和SyncThing。我为每个想要代理的网址添加了多个ProxyPass命令。

OwnCloud侦听端口80,因此需要绕过代理。 SyncThing在URL

后需要一个尾部斜杠
<VirtualHost *:80>
    ServerName server.com
    ProxyRequests Off
    ProxyPreserveHost On

    #let owncloud pass straight through
    ProxyPass /owncloud !

    #syncthing doesn't work without a trailing slash in browser URL
    RewriteRule ^/syncthing$ /syncthing/ [R]
    ProxyPass /syncthing/ http://127.0.0.1:8384/
    ProxyPassReverse /syncthing/ http://127.0.0.1:8384/

    #default go to plex
    ProxyPass / http://127.0.0.1:32400/
    ProxyPassReverse / http://127.0.0.1:32400/

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/web
    RewriteCond %{HTTP:X-Plex-Device} ^$
    RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>
相关问题