2017-02-24 2 views
0

Ich habe Kibana auf localhost:5601 hören und wenn ich SSH tunnel zu diesem Port kann ich auf Kibana in meinem Browser gut zugreifen.Reverse-Proxy von Kibana hinter Nginx - "Upstream vorzeitig geschlossen Verbindung"

Ich habe Nginx installiert, um als ein Reverse-Proxy zu fungieren, aber nach Abschluss der Installation alles, was ich bekomme ist 502 Bad Gateway. Je detaillierter Fehler in dem nginx Fehlerprotokoll wird

*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" 

Mein nginx config:

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; 
} 

Meine kibana.conf Datei innerhalb /etc/nginx/conf.d/ ist:

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; 
    } 
} 

Dies ist ein brandneues Amazon Linux EC2-Instanz mit den neuesten Versionen von kibana und nginx installiert.

Hat jemand dieses Problem schon einmal erlebt? Ich habe das Gefühl, dass es ein einfaches nginx-Konfigurationsproblem ist, aber ich kann es einfach nicht sehen.

Antwort

0

Es stellt sich heraus, dass die Schrägstriche vor den Dollar proxy_set_header Upgrade \$http_upgrade; ein Ergebnis einer Copy-Paste aus einem anderen Konfigurations-Management-Tool waren.

Ich entfernte die unnötigen Schrägstriche, um zu machen, und forderte meine Vernunft zurück.

Verwandte Themen