2016-09-15 148 views
1

我在Apache Web服務器後面運行我的Apache Zeppelin實例,其中的web服務器僅用作預留代理服務器。Apache反向代理服務器後面的Apache Zeppelin

如果我正在瀏覽反向代理網站https://my-domain.com/zeppelin/我收到了一個包含資產和按鈕以及所有內容的網站,但Zeppelin的websocket將無法連接。 Browser-Dev-Tools在說405 HTTP method GET is not supported by this URL爲URL https://my-domain.com/zeppelin/ws

如果我要直接在Zeppelin網站上(f.e. http://priv.my-domain.com/zeppelin),一切正常。所以它似乎不是Zeppelin-Code中的錯誤,而是反向代理配置中的一個問題。

我的Apache反向代理的配置是這樣的:

<VirtualHost *:443> 
    ServerName my-domain.com 
    # don't loose time with IP address lookups 
    HostnameLookups Off 
    ProxyRequests Off 
    ProxyPreserveHost Off 
    SSLEngine On 
    SSLProxyEngine On 
    SSLProxyVerify none 
    SSLProxyCheckPeerCN off 
    SSLProxyCheckPeerName off 
    ... 
    ssl cert stuff 
    ... 
    <Location /zeppelin/ws> 

     ProxyPass ws://priv.my-domain.com:8080/zeppelin/ws 
     ProxyPassReverse ws://priv.my-domain.com:8080/zeppelin/ws 

     Order deny,allow 
     Deny from all 

     Allow from <my-ip> 

    </Location> 

    <Location /zeppelin/> 

     ProxyPass http://priv.my-domain.com:8080/zeppelin/ 
     ProxyPassReverse http://priv.my-domain.com:8080/zeppelin/ 

     Order deny,allow 
     Deny from all 

     Allow from <my-ip> 

    </Location> 
    <Proxy *> 
     AddDefaultCharset Off 
     Order deny,allow 
     Allow from all 
    </Proxy> 
</VirtualHost> 

這沒有什麼區別,如果我刪除從配置第一WS-位置。 你有什麼想法嗎?

EDIT FOR SOLUTION:在下面的答案後,我修改了我的conf文件,現在它正在工作!非常感謝你!

我工作的conf:

<VirtualHost *:443> 
    ServerName my-domain.com 
    # don't loose time with IP address lookups 
    HostnameLookups Off 
    ProxyRequests Off 
    ProxyPreserveHost Off 
    SSLEngine On 
    SSLProxyEngine On 
    SSLProxyVerify none 
    SSLProxyCheckPeerCN off 
    SSLProxyCheckPeerName off 
    ... 
    ssl cert stuff 
    ... 
    <Location /zeppelin/> 

     ProxyPass http://priv.my-domain.com:8080/zeppelin/ 
     ProxyPassReverse http://priv.my-domain.com:8080/zeppelin/ 

     Order deny,allow 
     Deny from all 

     Allow from <my-ip> 

    </Location> 
    RewriteEngine On 
    RewriteCond %{HTTP:Upgrade} =WebSocket [NC,NV] 
    RewriteRule ^/(.*) ws://priv.my-domain.com:8080/$1 [P] 
    <Proxy *> 
     AddDefaultCharset Off 
     Order deny,allow 
     Allow from all 
    </Proxy> 
</VirtualHost> 

回答

2

這是我使用的有一些指定不一定適用於您的需求的conf:
- 每一個實例 - 在mesos集羣
前服務發現用戶和路由基於證書的用戶

<VirtualHost *:3128> 
    <Location "/"> 
     AuthUserFile /.............../users 
     AuthName "xxxxxxxxxxxxx" 
     AuthGroupFile /dev/null 
     AuthType Basic 
     Require valid-user 
    </Location> 
    ServerName xxxxxxxxxxxxxxxxxxxxxxxxxxx 
    # SSLEngine on 
    # SSLCertificateFile "/.............../xxxxx.crt" 
    # SSLCertificateKeyFile "/.............../xxxxx.key" 

    #RewriteRules for datalab with user 
    RewriteCond %{HTTP:Upgrade} =WebSocket [NC,NV] 
    RewriteCond %{LA-U:REMOTE_USER} (aaaa) 
    RewriteRule ^/(.*) ws://azerty01:31321/$1 [P] 
    RewriteCond %{LA-U:REMOTE_USER} (aaaa) 
    RewriteRule ^/(.*) http://azerty01:31321/$1 [P,QSA,L] 
    ProxyPassReverse/http://azerty01:31321 

    #RewriteRules for datalab with user 
    RewriteCond %{HTTP:Upgrade} =WebSocket [NC,NV] 
    RewriteCond %{LA-U:REMOTE_USER} (bbbb) 
    RewriteRule ^/(.*) ws://azerty02:31901/$1 [P] 
    RewriteCond %{LA-U:REMOTE_USER} (bbbb) 
    RewriteRule ^/(.*) http://azerty02:31901/$1 [P,QSA,L] 
    ProxyPassReverse/http://azerty02:31901 

</VirtualHost> 
+0

謝謝,它現在工作!查看我編輯的簡化Rewrite-Part無用戶身份驗證。 – BeerCamper

1

這裏是一個包括我時,我想反向代理0創建的文件Zeppelin服務器。如果您願意,您可以或多或少地將其剪切並粘貼到虛擬主機conf文件中。

# 
# Apache Reverse Proxy settings for Zeppelin server. 
# note: 
# Change ZEPPELING_IP_OR_HOST and ZEPPELIN_PORT as appropriate. 
# 
# FreeBSD put into /usr/local/etc/apache24/Includes directory, 
# Linux may vary. 

# This is for your-host.your-domain.com/zeppelin 
# if you want zeppelin.your-host.your-domain.com 
# Put this into a vhosts file. 

RequestHeader set X_FORWARDED_PROTO 'https' 
ProxyPreserveHost On 
RequestHeader set X-Forwarded-Port "443" 
ProxyRequests  Off 
ProxyVia Off 
AllowEncodedSlashes NoDecode 


<Location /zeppelin/ws> 
    ProxyPass ws://ZEPPELIN_IP_OR_HOST:ZEPPELIN_PORT/zeppelin/ws 
    ProxyPassReverse ws://ZEPPELIN_IP_OR_HOST:ZEPPELIN_PORT/zeppenlin/ws 
</Location> 

ProxyPass  /zeppelin  http://ZEPPELIN_IP_OR_HOST:ZEPPELIN_PORT/zeppelin 
ProxyPassReverse /zeppelin  http://ZEPPELIN_IP_OR_HOST:ZEPPELIN_PORT/zeppelin 
0

我想補充這一點,我能夠Apache2中使用下面的配置重新路由到我的飛艇實例。重要的部分是websocket連接。

請務必添加

sudo a2enmod proxy_wstunnel 

到MODS的。然後我跑了以下內容:

sudo a2dissite 000-default 
sudo nano /etc/apache2/sites-available/proxy-host.conf 
    # Insert the following into the proxy-host.conf file 
    <VirtualHost *:80> 
     ServerName '<Zeppelin Public IP>:8080' 
     RewriteEngine On 
     RewriteCond %{HTTP:Upgrade} =websocket [NC] 
     RewriteRule /(.*)   ws://<Zeppelin Public IP>:8080/$1 [P,L] 
     RewriteCond %{HTTP:Upgrade} !=websocket [NC] 
    RewriteRule /(.*)   http://<Zeppelin Public IP>:8080/$1 [P,L] 
    ProxyPassReverse/http://<Zeppelin Public IP>:8080/ 
    </VirtualHost> 
    #/text insert 
sudo a2ensite proxy-host 
sudo nano /etc/apache2/ports.conf 
    #Add this to the ports.conf file and cntrl+X to save & exit 
    Listen 8080 
sudo /etc/init.d/apache2 restart 

然後,當你去到http:// reverseproxypublicIP /它會重新路由到您的齊柏林實例。希望這可以幫助別人!