Skip to content

Instantly share code, notes, and snippets.

@ajaxray
Created February 16, 2018 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajaxray/f17f727848dd77778fa9610b99064fa2 to your computer and use it in GitHub Desktop.
Save ajaxray/f17f727848dd77778fa9610b99064fa2 to your computer and use it in GitHub Desktop.
Serve go / Golang HTTP/HTTPS app with Nginx as a subdomain
upstream go-http-backend {
server 127.0.0.1:3000;
keepalive 20;
}
server {
listen 80;
server_name sub.domain.com;
# adjust as per app's requirement
access_log off;
error_log /dev/null crit;
# required for keepalives to be used
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
location / {
proxy_pass http://go-http-backend;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment