Deploying NGINX Proxy Manager on Docker
3 min read

Deploying NGINX Proxy Manager on Docker

So you need a proxy server for whatever reason. Usually I use a proxy if I have more sites than I can handle via my router. I certainly don't want to run 6 nginx containers and I definitely don't want to use different ports other than standard ones.
Deploying NGINX Proxy Manager on Docker

So you need a proxy server for whatever reason. Usually I use a proxy if I have more sites than I can handle via my router. I certainly don't want to run 6 nginx containers and I definitely don't want to use different ports other than standard ones. What to do?

NGINX Proxy Manager for so many reasons but the main ones, I can run the websites on differents ports, I can get ssl certs and apply them without touching the server, Load Balancing in a small way, Caching and much more.

If you are doing this via cli on the host. You would make sure you create yourself a directory on the host that you want to create this on:

sudo mkdir -p /protjects/npm

sudo touch /projects/npm/docker-compose.yml

copy & paste the text below in to the create file:

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "admin" # Change mysql user
      DB_MYSQL_PASSWORD: "changeme" # Change mysql password
      DB_MYSQL_NAME: "npm"
    volumes:
      - /srv/config/nginxproxymanager:/data
      - /srv/config/nginxproxymanager/letsencrypt:/etc/letsencrypt
  db:
    image: 'jc21/mariadb-aria:10.4'
    environment:
      MYSQL_ROOT_PASSWORD: 'npm' # Change mysql user
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'admin' # Change mysql user
      MYSQL_PASSWORD: 'changeme' # Change mysql user
    volumes:
      - /srv/config/nginxproxymanager/db:/var/lib/mysql

at the cli run -> docker-compose -c /path/to/file/docker-compose.yml -d

then go to the host and run docker ps -a check for something similar to below

docker ps -a

That will be the end of the cli, now I will show you how to do this in Portainer.

Portainer Deployment

Login to Portainer

Goto Stacks in the navigation menu

Choose your Cluster

In the stacks portion click Add stack

Add stack

Create a stack, give your stack a name then

Copy & paste the following in to the web editor:

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "admin" # Change mysql user
      DB_MYSQL_PASSWORD: "changeme" # Change mysql password
      DB_MYSQL_NAME: "npm"
    volumes:
      - /srv/config/nginxproxymanager:/data
      - /srv/config/nginxproxymanager/letsencrypt:/etc/letsencrypt
  db:
    image: 'jc21/mariadb-aria:10.4'
    environment:
      MYSQL_ROOT_PASSWORD: 'npm' # Change mysql user
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'admin' # Change mysql user
      MYSQL_PASSWORD: 'changeme' # Change mysql user
    volumes:
      - /srv/config/nginxproxymanager/db:/var/lib/mysql

Then click deploy stack

Click deploy stack when you have made all your choices.

Goto Stacks List again

Look for your deployment

Click on the stack name

Check to make sure both services are running.

You should be good to go and everything running fine. You can now go to the host http://ip.of.srvr:81 and get the management portion of your application.

login: admin@example.local password: changeme
You should see all the selections with 0's in them.
Notice the Highlighted ones they are SSL enabled via NPM, I didn't have to touch the weserver at all.

So that does it for this article, This was just 2 methods of deploying NGINX Proxy Manager. I hope this helps you with your Hosting/Load Balancing of websites.

If you need assistance or clarity on this just contact us and we will be happy to help anyway we can.

Thank you for stopping by and your patience, Have an awesome day ya'll!