Way back in https://macblaze.ca/?p=14445 I set up Nginx to  handle port forwarding to my home computer. Since then I have modified it a bot and I wanted to make a not of those mods here.

Site in a subfolder

  • I have the subdomain xxx.macblaze.ca.
  • I want to have it access a site at 192.168.1.xx:8080
  • in a folder /folder

Set up the subdomain as usual

  1. go to Custom Locations
  2. location /
  3. Forward Hostname/IP 192.168.1.xx/folder
  4. Forward Port 8080

Docker container

  • ensure the container and Nginx’s container are on the same network. (current code method)

Set up the subdomain as usual

  1. go to Details
  2. Forward Hostname/IP <container-name> (get using docker ps --format "{{.Names}}")
    or Container IP
  3. Forward Port <the internal port>

 

Two Sites/Apps on one subdomain

  • I have the subdomain xxx.macblaze.ca.
  • I want to have it access a site at 192.168.1.xx1:8080
  • I want the subdomain xxx.macblaze.ca/app to access an app at 192.168.1.xx2:8080

Set up

  1. the subdomain as usual for the site
  2. go to Advanced Locations
  3. Add:
    location /app {
        proxy_pass http://192.168.1.xx2:8080/;
    }
    location /app/ {
        proxy_pass http://192.168.1.xx2:8080/;
    }