2015-09-30 64 views
0

我試圖讓Plex和OwnCloud都能與Apache一起工作。我目前正在設置Plex,來自http://server.com/的請求會被重寫並代理到localhost:32400/web/。我做到這一點具有以下配置:Apache重寫多個REQUEST_URI

<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未被代理或重寫。我有一個規則來檢查REQUEST_URI中的/owncloud,但它似乎沒有工作。

chrome debugger

http://server.com/owncloud

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

它看起來像它的拉動主要頁面了,但沒有任何腳本是基於調試解決所時,我得到如下回應

當我完全禁用虛擬主機時,OwnCloud URL可以正常工作。

從閱讀Apache文檔我相信如果重寫條件失敗,代理不會發生?

回答

0

與Plex,OwnCloud和SyncThing一起工作。我爲每個想要代理的URL添加了多個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>