The blog about containerisation, virtual machines and useful shell snippets and findings

How to debug jwilder/nginx-proxy

It’s common when you use nginx-proxy by jwilder. It supports SSL in clever way, handy configuration for containers via environment variables, but sometimes issues happened. How can I debug it?

First, check container logs with

docker logs nginx-proxy

then run nginx configuration test with

docker exec nginx-proxy nginx -t

nginx-proxy container should be up and running

In case no issues you should receive output something like this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful.

Otherwise number of line with issue will be reported.

Then you should verify configuration, the simplest way is to exec following command:

docker exec nginx-proxy cat /etc/nginx/conf.d/default.conf

I tackled some weird issues when:

  1. I use docker-compose version 2, and nginx-proxy does not have access to frontend network. In this case you should list
docker network ls

to find out yout frontend network name.
NETWORK ID NAME DRIVER
7fcacd901d8b bridge bridge
4c795ffb838a  itservice_front-tier bridge
ac4c6aeaf804 itservice_back-tier bridge
55d3d40d2390 none null
d0c498886500 host host

then

docker connect itservice_front-tier nginx-proxy

and container become accessible.

  1. In case container expose several ports, like odoo container, and none of them is 80 or 443, you should point with VIRTUAL_PORT proper port for proxying. In my case default.conf configuration of nginx pointed that docker container
server 172.17.0.5 down;

is visible, but down. After specifying VIRTUAL_PORT all things has been resolved.