External Connections
Router Configuration
In order to receive traffic from outside the network, you need to enable port forwarding from your router settings. To do this, you set up rules for TCP ports 80 and 443 to forward to your server's local IP. It is recommended to assign a static local IP to your server.
Nginx Proxy Manager
After the router has been configured to forward traffic to the server, you can then use Nginx to forward traffic to the correct container based on the url accessed. To do this you will need to run Nginx Proxy Manager on its own nginx
network. Other containers that you want exposed to the internet will then need to be added to this network so they can be exposed.
Creating Proxy Hosts
Proxy Hosts are the endpoints that will connect your containers to the outside world. Enter your domain name, and then select the protocol that the image uses locally (this will depend on the image). Then use the hostname that you configure in the container's network settings. Check "Cache Assets", "Block Common Exploits", and "Websockets Support". Under the SSL tab, create a new certificate for the process and check "Force SSL", "HTTP/2 Support", and "HSTS Enabled".
Adding containers to Nginx network
In order to the route from Nginx to the container, you will need to add the container to the correct network. In the network settings, select the nginx
network and set the hostname to something you will use to connect from Nginx, usually just the name of the process.
DDNS
DDNS, or Dynamic DNS, is required to link the router's IP to the domain registry. Since a home network IP can change, this needs to be updated regularly so the domain can link back to the correct home network. I use Google DDNS and followed this guide to set up my local server. Below is my configuration of ddclient.
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf
daemon=300
ssl=yes
protocol=dyndns2
use=web
server=domains.google.com
login='<login>'
password='<password>'
ddns.dietrick.dev
DNS
To setup new subdomains and route them to the correct applications, you then just need to create a CNAME entry pointing to your DDNS endpoint, in my case ddns.dietrick.dev
. This should automatically route you to the home network, through Nginx, and to the correct application.