Nginx反向代理Zeppelin

        Zeppelin在用户登陆和解释器配置等配置在相关的接口是通过http协议进行交互外,而Note和段落管理是通过Websocket进行交互,所以在nginx重代理Zeppelin时需要启用websocket反向代理支持。

# Nginx代理配置如下:

worker_processes  1;
​
events {
    worker_connections  1024;
}
​
http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }
 
    upstream zeppelin {
        # 这里的localhost:8080需要替换成你自己的zeppelin服务地址    
        server localhost:8080 weight=2 max_fails=2 fail_timeout=2;
    }
    
    server {
        listen 80;
        server_name zeppelin.proxy.com;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
​
        real_ip_header    X-Forwarded-For;
        real_ip_recursive on;
​
        location / {
            proxy_set_header Host $host:$server_port;
            proxy_http_version 1.1;
            proxy_connect_timeout 40s;
            proxy_read_timeout 120s;
            proxy_send_timeout 60s;
            proxy_pass http://zeppelin;
            
            # websocket代理相关请求头配置               
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
         }
    }
}

发表评论