简体   繁体   中英

With docker reverse proxy [emerg] 1#1: host not found in upstream

I created reverse proxy for netbox-docker image. It is custom reverse proxy for SSL, but when I start it, docker logs for container say this when it crashes:

Docker image and tutorial what I followed is here: https://github.com/netbox-community/netbox-docker/blob/release/README.md

[emerg] 1#1: host not found in upstream "netbox" in /etc/nginx/conf.d/proxy_ssl.conf:27

Ma nginx configuration for netbox container is here:

daemon off;
worker_processes 1;

error_log /dev/stderr info;

events {
    worker_connections 1024;
}

http {
    include              /etc/nginx/mime.types;
    default_type         application/octet-stream;
    sendfile             on;
    tcp_nopush           on;
    keepalive_timeout    65;
    gzip                 on;
    server_tokens        off;
    client_max_body_size 10M;

    server {
        listen      8080;
        access_log  off;

        location /static/ {
            alias /opt/netbox/netbox/static/;
        }

        location / {
            proxy_pass http://netbox:8001;
            proxy_set_header X-Forwarded-Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Proto $scheme;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
        }
    }
}

and nginx for reverse proxy is here:

server {
        listen 8000;
        listen [::]:8000;

        server_name domain.tld;
        return 301 https://$host$request_uri;

}

server {

        listen 8443 ssl http2;
        listen [::]:8443 ssl http2;

        server_name domain.tld;

        location /static/ {
            alias /opt/netbox/netbox/static/;
        }


        location / {
                #proxy_set_header X-Real-IP $remote_addr;
                #proxy_buffering off;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header Host $host;
                proxy_pass http://netbox:8001/;
        }

    ssl_certificate     /etc/nginx/conf.d/domain.crt;
    ssl_certificate_key /etc/nginx/conf.d/domain.key;
    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5;

}

Solved. I had to put the domain.tld into proxy_pass url, since docker containers are on same docker network, thats probably why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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