首页 文章

Apache Zeppelin落后于Apache反向代理

提问于
浏览
1

我正在Apache Web服务器后面运行我的Apache Zeppelin实例,其中web服务器仅用作保留代理 .

如果我正在浏览反向代理站点 https://my-domain.com/zeppelin/ 我'm getting a website with assets and buttons and everything, but the websocket of Zeppelin won' t connect . Browser-Dev-Tools为URL https://my-domain.com/zeppelin/ws405 HTTP method GET is not supported by this URL .

如果我直接去Zeppelin网站(f.e. http://priv.my-domain.com/zeppelin ),一切正常 . 因此,似乎它不是Zeppelin-Code中的错误,而是reverse-proxy-config中的问题 .

我的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-location,则没有任何区别 . 你知道吗?

编辑解决方案:在下面的答案后我修改了我的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>

3 回答

  • 0

    这是我正在使用的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>
    
  • 3

    这是我想要反向代理Zeppelin服务器时创建的Includes文件 . 如果愿意,您可以或多或少地将其剪切并粘贴到vhosts 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
    
  • 1

    只是为了补充一点,我能够使用Apache2和下面的配置重新路由到我的zeppelin实例 . 重要的是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 /它将重新路由到你的Zeppelin实例 . 希望这有助于某人!

相关问题