Don't couple your Go code to GitHub
server { server_name go.iain.rocks; root /var/www/go.iain.rocks; index index.html; location / { # Check if the query string does NOT contain 'go-get=1'. # The '~' is for a case-sensitive match. if ($args !~ go-get=1) { # This is a human visitor. Issue a permanent redirect to GitHub. # $request_uri will be the path, e.g., /boneclone return 301 https://github.com/that-guy-iain$request_uri; } # If it's the Go tool (with ?go-get=1), serve the HTML file as before. try_files $uri $uri/ =404; } # --- Your SSL configuration from Certbot should remain here --- listen 443 ssl; listen [::]:443 ssl; ssl_certificate /etc/letsencrypt/live/go.iain.rocks/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/go.iain.rocks/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; } # The HTTP to HTTPS redirect block should also remain. server { listen 80; listen [::]:80; server_name go.iain.rocks; return 301 https://$host$request_uri; }