2017-02-24 68 views
0

我有kibana在localhost:5601監聽,如果我SSH隧道到這個端口,我可以在我的瀏覽器中訪問kibana就好了。反向代理的背後nginx kibana - 「上游過早關閉連接」

我已經安裝nginx作爲反向代理,但完成設置,我得到的是502 Bad Gateway。在nginx的錯誤日誌中的更詳細的錯誤是

*1 upstream prematurely closed connection while reading response header from upstream, 
client: 1.2.3.4, 
server: elk.mydomain.com, 
request: "GET /app/kibana HTTP/1.1", 
upstream: "http://localhost:5601/app/kibana" 

我的nginx的配置是:

user nginx; 
worker_processes auto; 
error_log /var/log/nginx/error.log; 
pid /var/run/nginx.pid; 

# Load dynamic modules. See /usr/share/nginx/README.fedora. 
include /usr/share/nginx/modules/*.conf; 

events { 
    worker_connections 1024; 
} 

http { 
    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"'; 

    access_log /var/log/nginx/access.log main; 

    sendfile   on; 
    tcp_nopush   on; 
    tcp_nodelay   on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 

    include    /etc/nginx/mime.types; 
    default_type  application/octet-stream; 

    # Load modular configuration files from the /etc/nginx/conf.d directory. 
    # See http://nginx.org/en/docs/ngx_core_module.html#include 
    # for more information. 
    include /etc/nginx/conf.d/*.conf; 

    index index.html index.htm; 
} 

kibana.conf/etc/nginx/conf.d/文件是:

server { 

    listen 80 default_server; 
    server_name elk.mydomain.com; 

    auth_basic "Restricted Access"; 
    auth_basic_user_file /etc/nginx/htpasswd.users; 

    location/{ 
     proxy_pass http://localhost:5601; 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade \$http_upgrade; 
     proxy_set_header Connection 'upgrade'; 
     proxy_set_header Host \$host; 
     proxy_cache_bypass \$http_upgrade; 
    } 
} 

這是一個全新的亞馬遜的Linux安裝了最新版本的kibana和nginx的EC2實例。

有沒有人遇到過這個問題?我覺得這是一個簡單的nginx配置問題,但我無法看到它。

回答

0

事實證明,美元proxy_set_header Upgrade \$http_upgrade;之前的斜線是來自另一個配置管理工具的複製粘貼的結果。

我刪除了不必要的斜槓,使proxy_set_header Upgrade $http_upgrade;和收回我的理智。

相關問題