Use NGINX reverse proxy to resove docker hosts


NGINX reverse proxy request

I use Docker to host my containers, and I love it, one thing I struggle with to remember the port number I’ve deployed the container on.

It makes a lot more sense to make a hostname rather than an IP address, this is where NGINX comes it, there is a lot of other awesome reverse proxies out there but the quickest and easiest for me was NGINX. I’ve deployed the latest NGINX container from the docker hub and was up and running within minutes.

But before we can configure the reverse proxy, you would need DNS entries to point your hostname to the NGINX container. I personally use Pi Hole for my DNS manager and as from version 5 you can add local DNS entries.

Pi hole with custom DNS local entries

As you can see all the DNS entries point to the same IP address, once you have setup your local DNS entries, the next part is to setup the reverse proxy.

For every DNS entry I’ve created a config file, log into the NGINX console and navigate to the /etc/nginx/conf.d/ directory. You now want to create a .conf file where you will setup your routing. In my case for I created grocy.conf

server {
  listen 80;
  server_name grocy.local;

  location / {

After saving the file, you can restart the NGINX service by typing service nginx restart

The NGINX will forward request on port 80 from grocy.local to

I’ve created a few more config files for each container and you are set. Quick and easy