HTTPS setup to encrypt connections to Gitea

Using the built-in server

Before you enable HTTPS, make sure that you have valid SSL/TLS certificates. You could use self-generated certificates for evaluation and testing. Please run gitea cert --host [HOST] to generate a self signed certificate.

If you are using Apache or nginx on the server, it’s recommended to check the reverse proxy guide.

To use Gitea’s built-in HTTPS support, you must change your app.ini file:

PROTOCOL  = https
HTTP_PORT = 3000
CERT_FILE = cert.pem
KEY_FILE  = key.pem

To learn more about the config values, please checkout the Config Cheat Sheet.

Setting up HTTP redirection

The Gitea server is only able to listen to one port; to redirect HTTP requests to the HTTPS port, you will need to enable the HTTP redirection service:

; Port the redirection service should listen on

If you are using Docker, make sure that this port is configured in your docker-compose.yml file.

Using Let’s Encrypt

Let’s Encrypt is a Certificate Authority that allows you to automatically request and renew SSL/TLS certificates. In addition to starting Gitea on your configured port, to request HTTPS certificates, Gitea will also need to listed on port 80, and will set up an autoredirect to HTTPS for you. Let’s Encrypt will need to be able to access Gitea via the Internet to verify your ownership of the domain.

By using Let’s Encrypt you must consent to their terms of service.


To learn more about the config values, please checkout the Config Cheat Sheet.

Using reverse proxy

Setup up your reverse proxy as shown in the reverse proxy guide.

After that, enable HTTPS by following one of these guides:

Note: Your connection between your reverse proxy and Gitea might be unencrypted. To encrypt it too, follow the built-in server guide and change the proxy url to https://[URL].