Skip to main content
Running Gogs behind a reverse proxy allows you to serve it on standard ports (80/443) with a clean and nice URL in the browser address bar, add TLS termination, and integrate with existing web server infrastructure.
Make sure the EXTERNAL_URL in your custom/conf/app.ini matches the actual URL users will access. When using a reverse proxy for TLS termination, keep PROTOCOL = http in Gogs and set EXTERNAL_URL to https://. The reverse proxy handles the encryption, and Gogs communicates with it over plain HTTP on the local network.
Serving Gogs under a subpath (e.g., https://example.com/gogs/) makes it share a browser origin with every other site on the same host. Requests from those sibling sites are treated as same-site, so the SameSite attribute on the session cookie offers no protection against them. A compromised or malicious sibling site can then mount CSRF attacks against Gogs, such as forging state-changing requests with the victim’s session. Only use a subpath when you fully trust every other application on the same host. Otherwise, serve Gogs on a dedicated subdomain.

Caddy 2

Add the following server block to your Caddyfile and reload:
Set the matching external URL in custom/conf/app.ini:
Caddy automatically provisions TLS certificates via Let’s Encrypt when you use a domain name.

NGINX

Add the following server block inside the http section of your nginx.conf (or in a file under sites-available), then reload the NGINX configuration:
Set the matching external URL in custom/conf/app.ini:

Large file uploads

If you encounter HTTP 413 Request Entity Too Large errors when pushing large files through NGINX, add client_max_body_size to your server block:
Adjust the client_max_body_size value to match or exceed the maximum file size you expect users to push. The default NGINX limit is only 1 MB.

Apache 2

Create or edit your virtual host configuration file (e.g. /etc/apache2/vhost.d/gogs.conf):
Set the matching external URL in custom/conf/app.ini:

lighttpd

Add the following to your lighttpd configuration:
Set the matching external URL in custom/conf/app.ini:

IIS

Create a new website in IIS and use the following web.config file.
If you do not need HTTPS handled by IIS, remove the entire RedirectToHttps rule section from the configuration below.
Then set the matching external URL in custom/conf/app.ini:

Native HTTPS

If you are not using a reverse proxy, Gogs can serve HTTPS directly. Update the [server] section of custom/conf/app.ini: