Skip to content

Setting up NGINX for GotHub

Note

NGINX does not support automatic certificate generation. You need to use certbot to create and maintain the certificates but that is out of scope of this tutorial. We also recommend you to try the Caddy web server, because it has automatic HTTPS, HTTP/3 and easier configuration.

After installing NGINX, create /etc/nginx/conf.d/gothub.conf with the following contents

server {
    listen 80;
    listen [::]:80;

    server_name gothub.domain.tld;

    # Recommended but not required
    access_log off;
    error_log /var/log/nginx/error.log crit;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;    # so GotHub knows domain
        proxy_http_version 1.1;     # to keep alive
        proxy_set_header Connection ""; # to keep alive
    }
}