nginx-proxy: [bug] Using certificates missing apps redirect to wrong apps
All seems to work as intended until I start using certificates.
Short description
I do:
- run nginx-proxy, app1 and app2 both on https,
- I kill app2,
- visit app2 in my browser, but get app1 certificates and results.
Long description
This is how I run nginx-proxy and both apps (app1 and app2).
docker run --name nginx-proxy -d -p 80:80 -p 443:443 -v /home/ubuntu/_certificates:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
docker run -d --name app1.app.com -e VIRTUAL_PROTO=https -e VIRTUAL_PORT=443 -p 8003:443 -e VIRTUAL_HOST=app1.app.com app
docker run -d --name app2.app.com -e VIRTUAL_PROTO=https -e VIRTUAL_PORT=443 -p 8005:443 -e VIRTUAL_HOST=app2.app.com app
I kill app2 with docker kill app2.app.com
.
Visit app2.app.com, but the certificate I get is from app1 and the contents as well. If I also kill app1, then I get the server not found, which is of course correct. If I then run app1 again, app2 again redirects to the wrong app.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 27 (6 by maintainers)
The solution is to implement a self-signed certificate in the proxy cert folder
Etc: openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout default.key -out default.crt
Then you get a 500 server error instead of another site.
I’m also facing the same problem. When the server container is stopped and request from browser using HTTP is not a problem (it correctly shows temporarily unavailable), but when using HTTPS it opens some other container which also uses HTTPS. I’m using letsencrypt-nginx-proxy-companion for HTTPS.