1

I am running nginx on ubuntu server, I have it configured as a wildcard SSL frontend proxy to various other services in my network. I port forward 443 on my router to nginx only, I use dynamic DNS to configure various hosts to point to my router IP, and for each host I forward to the respective internal server. This is pretty standard stuff, and works very well, e.g. I expose my security camera NVR, UniFi controller, Plex, etc.

I am in the process of converting my setup to docker, and with nginx as a proxy I ran into a problem:

[emerg] 1#1: host not found in upstream "plex.home.foo.net" in /etc/nginx/nginx.conf:80

I found many many references to this "host not found in upstream" error when running nginx as a reverse proxy in docker, with a variety of solutions, most dealing with proxying to other containers, but none that I can get working.

E.g. add an explicit resolver to point to docker google DNS, "resolver 127.0.0.11", did not make a difference.

E.g. use a variable instead of a FQDN, but nginx does not support variables in "proxy_redirect default" blocks.

E.g. pass in the host name as a parameter "--add-host="plex.home.foo.net:192.168.1.47", but that defeats the purpose of DNS.

E.g. use static IP's instead of FQDN's, but that defeats the purpose of DNS.

E.g. https://github.com/nginxinc/docker-nginx/issues/78

Before I spend too much time on this, anybody using nginx as a reverse proxy running in docker but proxying servers outside of docker?

Snippet from nginx.conf:

proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

server {
    listen 443 ssl;
    server_name xprotect.foo.net;

    location / {
        proxy_pass http://xprotect.home.foo.net:8081;
        proxy_redirect default;
        proxy_redirect http:// $scheme://;
    }
}
  • Would software like Squid be more appropriate for what you're trying to achieve? – Tim Apr 16 '18 at 0:45
0

Thanks John for pointing me here: https://development.robinwinslow.uk/2016/06/23/fix-docker-networking-dns/

nginx.conf resolver did not work:

resolver 192.168.1.1;

Docker DNS option did work:

--dns=192.168.1.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.