Skip to content

Instantly share code, notes, and snippets.

@thiemok
Last active April 30, 2022 10:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thiemok/f7ad440c2d358e531e4a3945603420cd to your computer and use it in GitHub Desktop.
Save thiemok/f7ad440c2d358e531e4a3945603420cd to your computer and use it in GitHub Desktop.
Gogs nginx ssl reverse proxy config
server {

    listen 443;
    server_name sub.domain.tld;

    ssl_certificate           /etc/nginx/server.crt;
    ssl_certificate_key       /etc/nginx/server.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    access_log            /var/log/nginx/access.log;

    location /git/ {

      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                 ^/git/(.*) /$1 break;
      rewrite                 ^/git$ /$1 break;
      proxy_pass          http://gogs.ip:3000;
      proxy_read_timeout  90;
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment