openssl req -x509 -newkey rsa:4096 -keyout private.key -out cert.pem -days 365 -sha256 -nodes -subj "/C=US"http://yourgame.me/.well-known/acme-challenge/<token>--standalone: Certbot answers the challenge itself on port 80
/etc/letsencrypt/live/yourgame.me/fullchain.pem/etc/letsencrypt/live/yourgame.me/privkey.pemsudo certbot renew gets a new oneyourgame.me → 3.89.120.15dig yourgame.me or nslookup yourgame.me$host and $request_uri are filled in by nginx for each requestserver {
listen 443 ssl;
server_name yourgame.me;
ssl_certificate /etc/letsencrypt/live/yourgame.me/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourgame.me/privkey.pem;
location / {
proxy_pass http://app:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}app is the name of your app's service in docker composelocation /websocket {
proxy_pass http://app:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
}ws:// connection
const protocol = location.protocol === "https:" ? "wss://" : "ws://";
const socket = new WebSocket(protocol + location.host + "/websocket");http://localhost:8080 and on your deployed domainX-Forwarded-Forapp.wsgi_app = ProxyFix(app.wsgi_app, x_for=1), then request.remote_addrapp.set("trust proxy", 1), then req.ipservices:
nginx:
image: nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- /etc/letsencrypt:/etc/letsencrypt:ro
app:
build: .
mongo:
image: mongodocker compose -f compose.yml -f compose.prod.yml up -d on the serverSecure directive to your auth cookies
http://localhost as secure
Demo