docker-nginx-ssl-proxy
docker-nginx-ssl-proxy copied to clipboard
UPSTREAM difficult to get right
I was unable to get the proxy pass working with my app container until I added the service to my existing docker-compose.yml and specified the app service name as the UPSTREAM: target
(where target
is the name of the docker container that is running the proxied app. Not 127.0.0.1, the local IP, LAN IP, nor even the docker IP that is randomly generated worked. Perhaps the network needs to be specified in the docker-compose.yml service description, perhaps there is some other nuance. None of this is documented.
The error I was getting was 502: Bad gateway
Docker logs on app were empty, logs on proxy read something like (I have obscured actual domains):
2022/10/06 19:03:13 [error] 145#145: *28 connect() failed (113: No route to host) while connecting to upstream, client: [redacted_request_ip], server: [redacted_domain], request: "GET / HTTP/2.0", upstream: "http://[redacted_lan_ip]:[redacted_app_port]/", host: "[redacted_domain]"
[redacted_request_ip] - - [06/Oct/2022:19:03:13 +0000] "GET / HTTP/2.0" 502 552 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/104.0.5112.101 Safari/537.36" "-"
10.0.18.17 - - [06/Oct/2022:19:03:23 +0000] "\x16\x03\x01\x00\xA3\x01\x00\x00\x9F\x03\x03\xDE\xBE\xD8ho" 400 150 "-" "-" "-"