Docker Nginx Proxy

Docker Nginx Proxy allow you to run multiple docker containers on same server behind nginx proxy. This is done using

https://github.com/jwilder/nginx-proxy

To do this, you need a server with port 80 and 443 unused.

To setup nginx proxy, run following

cd /root/
git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git
cd docker-compose-letsencrypt-nginx-proxy-companion
cp .env.sample .env
./start.sh

This will start nginx proxy. You can modify .env file if you want.

Starting a Docker Web App Behind Proxy

To start a web app, all you need is to start docker container on same network as nginx proxy. By default it is “webproxy”.

Here is an example command to start a web server.

docker run -d 
    -e VIRTUAL_HOST=test.serverok.in \
    -e LETSENCRYPT_HOST=test.serverok.in \
    -e [email protected] \
    --network=webproxy \
    --name my_app \
    httpd:alpine

This will start a test web server. You need to point the domain specified to this servers IP, then only nginx proxy can get LetsEncrypt SSL installed.

Replace test.serverok.in with your actual domain.

If you don’t want LetsEncrypt SSL installed, you can remove following 2 options

    -e LETSENCRYPT_HOST=test.serverok.in \
    -e [email protected] \
Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *