Awesome Open Source
Awesome Open Source

NGINX Proxy Automation

What this project does

This script will power up your new server with the nginx-proxy, where you will be able to host multiple sites, auto renewing Let´s Encrypt certificates! ❤️

Something like:

Web Proxy environment

We strongly recommend you (please do! 🙏) to read all documentation before starting in production as well as the nginx-proxy docs.

To access the previous version of this project please access version 0.4.

Upgrading from previous version

If you are upgrading from the previous version please follow the guide below carefully:

Video Tutorial

I made a 5 minutes tutorial video to walk you through this project:

Click here to access the video or click the image below:



  1. Linux! 🐧 (just in case...)

Please check all requirements at requirements.

In order to use this compose file (docker-compose.yml) you must have:

  1. Docker installed (

  2. Docker-compose installed (

I have an easy-server for myself which I use to install docker and docker-compose in new servers and some aliases and other stuff. Feel free to use it, but it is not related to this repo and maintainance it's for my own use only. Check './install/docker' folder.

Also, you will need to make sure you have:

  1. Port 80 and 443 available for binding - which means apache/nginx or other web services should not be running in your server

  2. Server must be accessible by a public IP address

How to use it

  1. Clone this repository using the option --recurse-submodules:
$ git clone --recurse-submodules proxy 

Make sure you use the option '--recurse-submodules' once we use an external module in this project, please check basescript

Please note we use 'proxy' as folder at the end. But you can change it to whatever fits you better

  1. Run the script ''
$ cd proxy/bin
$ ./

This script will walk you through all config process.

When it finishes you are good to go! 🏁

If you are in a 'hurry' you could use just $ ./ --yes -e [email protected] (please set your email) and your proxy will start it as soon as possible.

You can check all available options to run the script $ ./ --help

  1. Fire your new site with the following options:
  [email protected]

The fresh start script asked you for the proxy network name if you changed set a name differente from the default please update the option 'NETWORK' in the examples below before running it.

  • Simple site without Let's Encrypt certificate
$ docker run -d -e \
              --network=proxy \
              --name my_app \
  • To have SSL in your web/app you must add the option -e, as follow:
$ docker run -d -e \
              -e \
              -e LETSENCRYPT_EMAIL=[email protected] \
              --network=proxy \
              --name my_app \

You don´t need to open port 443 in your container, the certificate validation is managed by the web proxy

Please note that when running a new container to generate certificates with Let's Encrypt (-e, it may take a few minutes

Further Options

  1. Basic Authentication Support

In order to be able to secure your virtual host with basic authentication, you must create a htpasswd file within ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST} via:

$ sudo sh -c "echo -n '[username]:' >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}"
$ sudo sh -c "openssl passwd -apr1 >> ${NGINX_FILES_PATH}/htpasswd/${VIRTUAL_HOST}"

Please replace the ${NGINX_FILES_PATH} with real path to information, replace [username] with your username and ${VIRTUAL_HOST} with your host's domain. You will be prompted for a password.

  1. Using different networks

If you want to use more than one network to better organize your environment you could set the option SERVICE_NETWORK in our .env.sample or you can just create your own network and attach all your containers as of:

docker network create myownnetwork
docker network connect myownnetwork nginx-web
docker network connect myownnetwork nginx-gen
docker network connect myownnetwork nginx-letsencrypt
  1. Ports

If your service container runs on port 8545 you probably will need to add the VIRTUAL_PORT environment variable to your container, in the docker-compose.yml, so it can be proxied, as of:

    image: parity/parity:v1.8.9
      VIRTUAL_PORT: 8545

Or as of below:

docker run [...] -e VIRTUAL_PORT=8545 [...]
  1. Restarting proxy container

In some cases you will need to restart the proxy in order to read, as an example, the Basic Auth, if you set it after your service container is already up and running. So, the way I use to restart the proxy (NGINX) is as following, which has no downtime:

docker exec -it ${NGINX_WEB} nginx -s reload

Where ${NGINX_WEB} is your proxy container name, which in the original .env file is set as nginx-web.

Testing nginx-proxy

  1. Run the script informing your domain already configured in your DNS to point out to your server as follow:

or simply run:

docker run -dit -e --network=webproxy --name test-web httpd:alpine

If you want to test the Let's Encrypt certificate as well use

Access your browser with your domain!

To stop and remove your test container run our script:


Or simply run:

docker stop test-web && docker rm test-web


If you are using this project in production enviroment, check all license involved and consider the following recomendation:

Other projects using nginx-proxy

Following are links to docker containers using this web proxy:

  1. docker-wordpress-letsencrypt
  2. docker-portainer-letsencrypt
  3. docker-nextcloud-letsencrypt
  4. docker-registry-letsencrypt
  5. gitlab-docker-letsencrypt
  6. docker-webtrees-letsencrypt

Running this Proxy on a Synology NAS

Please checkout this howto.


Without the projects below this proxy would be impossible:

Supporting | Sponsoring ♥️

In case you are willing to support this project, check:

List of all contributers, supporters, sponsors and backers

Please access the page Supporters, Sponsors and Backers.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
shell (10,204
docker (2,851
nginx (482
docker-compose (390
letsencrypt (140
certificate (97
nginx-proxy (24