gogs on nginx

Nginx Aug 7, 2018

Gogs is a painless self-hosted Git service. It's much smaller than GitLab so it has much lower system requirements. I'm running it on a RPI2.

Gogs is running on http://localhost:3000
So we need nginx to serve our git service to the internet.

To achieve this add the following lines in your server config file (e.g. /etc/nginx/sites-available/default)

    location /gogs {

      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;

      rewrite                 ^/gogs/(.*) /$1 break;
      rewrite                 ^/gogs$ /$1 break;
      proxy_pass              http://localhost:3000;
      proxy_read_timeout      90;
    }

reload nginx

service nginx reload

access gogs over nginx
http://localhost:80/gogs

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.