Peters School of Business · Assiniboine College · NETW-0014
2 hours · Lab 6D · proxy_pass to a container, DNS record, full end-to-end verification
Map the full chain before writing a single line of config
Lab 6D — Deploy a Docker web app, proxy through Nginx, wire up DNS
Part 1 — Deploy the Docker web application (20 min)
mkdir -p ~/app && echo "<html><body><h1>Served from Docker</h1><p>Container: app.yourname.net</p></body></html>" > ~/app/index.html
mkdir -p ~/docker/app && nano ~/docker/app/docker-compose.yml
services:
app:
image: nginx
ports:
- "8080:80"
volumes:
- ~/app:/usr/share/nginx/html:ro
restart: unless-stopped
docker-compose up -d (from ~/docker/app/). Verify: curl http://localhost:8080 — should return the "Served from Docker" page. Check: docker-compose ps — service Up.Part 2 — Add a DNS record for app.yourname.net (15 min)
app A 192.168.50.1 (internal clients go directly to S1's LAN1 IP)
app A 172.17.[S1-external] (external clients use S1's external IP)
sudo systemctl reload named. Verify: dig @192.168.50.1 app.yourname.net — should return the internal IP. From Windows: nslookup app.yourname.net [S1-external-IP] — should return the external IP.Part 3 — Configure Nginx reverse proxy for app.yourname.net (30 min)
sudo nano /etc/nginx/sites-available/app.yourname.net
server {
listen 80;
listen [::]:80;
server_name app.yourname.net;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
server_name app.yourname.net;
access_log /var/log/nginx/app.yourname.net.access.log;
error_log /var/log/nginx/app.yourname.net.error.log;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
sudo ln -s /etc/nginx/sites-available/app.yourname.net /etc/nginx/sites-enabled/sudo nginx -t — must pass.
sudo systemctl reload nginx
Part 4 — End-to-end verification (30 min)
nslookup app.yourname.net [S1-external-IP] returns S1's external IP ✓
sudo nginx -t passes, sudo systemctl status nginx shows active ✓
curl -k https://localhost/ with Host header: curl -k -H "Host: app.yourname.net" https://localhost/ returns the Docker app page ✓
docker-compose ps from ~/docker/app/ shows app service Up ✓
sudo tail -f /var/log/nginx/app.yourname.net.access.log — watch entries appear as you reload the browser ✓
docker-compose logs app — should show the Nginx access log entry for the proxied request.Course arc reflection and Week 7 preview
Learning outcomes — by end of Day 4, students can…
Common issues and fixes
| Issue | Likely cause | Fix |
|---|---|---|
| Nginx returns 502 Bad Gateway | Docker container not running, or proxy_pass pointing to wrong port | Check: docker-compose ps — is the app service Up? Check: curl http://localhost:8080 — does it return the app page directly? If not, container issue. If yes, proxy_pass port is wrong in the Nginx config |
| Browser shows yourname.net page instead of app page | server_name in the app.yourname.net block doesn't match the hostname, or symlink not created | Check: sudo nginx -T | grep server_name — app.yourname.net should appear. Check: ls /etc/nginx/sites-enabled/ — symlink should exist |
| DNS record for app.yourname.net not resolving | Serial number not incremented, or named not reloaded after zone file change | Verify serial is higher than before in the zone file. Reload: sudo systemctl reload named. Check: dig @192.168.50.1 app.yourname.net |