NGINX Proxy Manager Logo I have recently been playing with NGINX Proxy Manager (NPM) due to the web based management capabilities it has. I recently had the need to host a static site behind NPM, but didn’t want to run another server….

Overview

Since I already have NPM running and listening on port 443, I want to avoid bringing up another web server just for a static site. This is a simple enough, low-traffic need, that it should be fine using the built-in NGINX that NPM already has running.

In my case, I am running NPM in Docker on a PhotonOS Virtual Machine using a simple docker-compose file:

 1version: "3"
 2services:
 3  app:
 4    image: jc21/nginx-proxy-manager:github-pr-966
 5    restart: always
 6    ports:
 7      # Public HTTP Port:
 8      - '80:80'
 9      # Public HTTPS Port:
10      - '443:443'
11      # Admin Web Port:
12      - '81:81'
13    environment:
14      # Uncomment this if IPv6 is not enabled on your host
15      DISABLE_IPV6: 'true'
16    volumes:
17      # Make sure this config.json file exists as per instructions above:
18      - ./config.json:/app/config/production.json
19      - ./data:/data
20      - ./letsencrypt:/etc/letsencrypt

As you can see, there is a data folder under the directory with the docker-compose.yml file. I’ll leverage that existing mapped folder for a static website.

How-To

  1. Create a new folder on your docker host in the data folder that is already mounted to your NPM container. For example md data/demo.lab
  2. Place your static file(s) in that folder - at least place a quick and simple index.html
  3. Go to your NPM UI and create a new Proxy Host
  4. Specify the FQDNs in the Domain Names box (In this case, I’m using an invalid TLD that cannot be publicly resolved: .demo.lab and www.demo.lab), select http, specify 127.0.0.1 and port 80

NPM New Proxy Host

  1. On the SSL tab, choose the SSL Certificate for the FQDNs specified for the Domain Names and enable Force SSL and HTTP/2 Support
  2. On the Advanced tab, enter the following text in the Custom Nginx Configuration:
1location / {
2  root /data/demo.lab;
3}

NPM New Proxy Host

  1. Update your appropriate internal DNS entries to point demo.lab and www.demo.lab to the internal address of your NPM server. This will allow your local users to resolve those URLs without going out your router.
  2. If working with a public domain, be sure to update your external DNS entries to point demo.lab and www.demo.lab to the external IP address of your NPM server.
  1. Visit your website in a browser and confirm its working!

  2. Finally, setup a pipeline or script to place your updated static site files in the data/demo.lab folder of your NPM Docker server.