简体   繁体   English

使用nginx作为反向代理运行Apache Zeppelin

[英]Running Apache Zeppelin with nginx as reverse proxy

In our current architecture we have two apache front servers, in front of them, we have an nginx load balancer. 在我们当前的架构中,我们有两个apache前端服务器,在它们之前,我们有一个nginx负载均衡器。 And in front of that an nginx reverse proxy. 并且在那之前是一个nginx反向代理。

My problem is that i'm trying to run Apache Zeppelin through the reverse proxy, and i'm having some problems with the websockets. 我的问题是我试图通过反向代理运行Apache Zeppelin,我遇到了一些websockets的问题。

I get an error like this : 400 HTTP method GET is not supported by this URL 我收到如下错误: 400 HTTP method GET is not supported by this URL

And here is a screenshot of what the Chrome's Networks tab shows : 以下是Chrome的“网络”标签显示的屏幕截图: 在此输入图像描述

I add my reverse proxy config for Zeppelin: 我为Zeppelin添加了反向代理配置:

error_log  /var/log/nginx/nginx_error.log  warn;
server {
    listen       80;
    server_name  localhost;

    location /zeppelin/ {
        proxy_pass http://zeppelin:8080/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade websocket;
        proxy_set_header Connection upgrade;
    }

    # fallback
    location / {
        return 301 http://ci.blablalablab.com/app/;
    }  
}

Zeppelin is running inside a docker container, and i have exposes the 8080 port, its host name is : zeppelin. Zeppelin在docker容器内运行,我公开了8080端口,它的主机名是:zeppelin。

If you have any questions on the architecture or so, don't hesitate to ask. 如果您对架构有任何疑问,请不要犹豫。

Thank you very much guys ! 非常感谢你们 !

you can add to your reverse proxy configuration 您可以添加到反向代理配置

location /ws {  # For websocket support
    proxy_pass http://zeppelin:8080/ws;
    proxy_http_version 1.1;
    proxy_set_header Upgrade websocket;
    proxy_set_header Connection upgrade;
    proxy_read_timeout 86400;
}

Reference: Zeppelin 0.7 auth docs 参考: Zeppelin 0.7 auth docs

After a lot of digging around, i ended up with this configuration : 经过大量的挖掘,我最终得到了这个配置:

location /zeppelin/ {
    proxy_pass http://zeppelin:8080/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_redirect off;
}


location /zeppelin/ws {
    proxy_pass http://zeppelin:8080/ws;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
}

This is working pretty good, thank you everyone for your efforts ;) 这工作得很好,谢谢大家的努力;)

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

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