How To Install Nginx Proxy Manager Via Docker

Setting up reverse proxies are a critical component of any internet facing server, my personal favorite proxy manager, Nginx Proxy Manager (NPM) is lightweight and easy to use with its modern graphical user interface.

Disclaimer

This guide is specifically designed for Ubuntu Server, but some parts of it may be generalizable to other operating systems, though compatibility is not guaranteed between operating systems and versions. If you would like to install Ubuntu Server click here for my full guide.

What you need

  • Computer
  • Ubuntu Server
  • Docker
  • Docker Compose
  • Premade Docker network (e.g. “proxy”)
  • Domain or Subdomain
  • Router Capable of Port Forwarding

Making the file structure

I like to keep my files organized per docker container. Using this guide’s file structure is recommended but not required. first make the folder, by navigating to your docker folder or the folder that you keep all of your docker containers in, in my case it is named docker.

~$ cd docker

Next make your WordPress folder, in this case it will be called “wordpress”

~/docker$ mkdir npm

Now navigate to the new directory

~/docker$ cd npm

Creating the files

Next we will create the docker-compose.yml file for NPM.

~/docker/npm$ nano docker-compose.yml

Once in the text editor, paste the following


services:
  npm:
    image: jc21/nginx-proxy-manager:latest
    container_name: npm
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "81:81"
    networks:
      - proxy
    environment:
      DB_SQLITE_FILE: "/data/database.sqlite"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
networks:
  proxy:
    external: true
    driver: bridge

Note: all highlighted text are placeholder values that can be changed based on your specific configuration, for example, you can name the service Nginx-Proxy-Manager instead of npm, and you can use a different network than proxy if you have a network already set up. you can also configure npm to create a network in its docker compose file but for the purposes of this guide, I will be using a pre-existing docker network.

The 81 external port can also be changed to any open port if 81 is not available.

Running the container

Now spin up the container.

~/docker/npm$ docker compose up

Check the logs to ensure there are no errors, and press d to detach. Next, go to the NPM webpage at http://”YourIpAddress”:81 (or whatever number you have mapped to the 81 port).

If you get an error or the webpage doesn’t load, try restarting the container before doing other troubleshooting steps, as I have found that restarting NPM can fix this.

~/docker/npm$ docker compose down
~/docker/npm$ docker compose up

or type

~/docker/npm$ docker restart npm

Once inside of the webpage, create an account.

Router Configuration

The final step to configuring npm is configuring port forwarding on your router. the process of this can vary from router to router but the processes are usually similar.

Add a port forwarding assignment for your server’s Ip address, and port forward 443 -> 443. Add a second assignment to forward port 80 -> 80.

To test that npm is properly working, make a proxy in npm to one of your services like wordpress. Click the link for a full guide for wordpress’s npm configuration and setup.

Once the proxy is up, you should be able to navigate to your web-server, from the external domain.

Note: if your router does not support NAT loopback, you will not be able to access the external domain from within your WIFI network without a VPN.

Congratulations! you have successfully installed Nginx Reverse Proxy Manager

Tags:

No responses yet

Leave a Reply

Latest Comments

No comments to show.