You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

https-support.md 2.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ---
  2. date: "2018-06-02T11:00:00+02:00"
  3. title: "Usage: HTTPS setup"
  4. slug: "https-setup"
  5. weight: 12
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "usage"
  11. name: "HTTPS setup"
  12. weight: 12
  13. identifier: "https-setup"
  14. ---
  15. # HTTPS setup to encrypt connections to Gitea
  16. ## Using the built-in server
  17. Before you enable HTTPS, make sure that you have valid SSL/TLS certificates.
  18. You could use self-generated certificates for evaluation and testing. Please run `gitea cert --host [HOST]` to generate a self signed certificate.
  19. If you are using Apache or nginx on the server, it's recommended to check the [reverse proxy guide]({{< relref "doc/usage/reverse-proxies.en-us.md" >}}).
  20. To use Gitea's built-in HTTPS support, you must change your `app.ini` file:
  21. ```ini
  22. [server]
  23. PROTOCOL = https
  24. ROOT_URL = https://git.example.com:3000/
  25. HTTP_PORT = 3000
  26. CERT_FILE = cert.pem
  27. KEY_FILE = key.pem
  28. ```
  29. To learn more about the config values, please checkout the [Config Cheat Sheet](../config-cheat-sheet#server).
  30. ### Setting up HTTP redirection
  31. 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:
  32. ```ini
  33. [server]
  34. REDIRECT_OTHER_PORT = true
  35. ; Port the redirection service should listen on
  36. PORT_TO_REDIRECT = 3080
  37. ```
  38. If you are using Docker, make sure that this port is configured in your `docker-compose.yml` file.
  39. ## Using Let's Encrypt
  40. [Let's Encrypt](https://letsencrypt.org/) 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.
  41. By using Let's Encrypt **you must consent** to their [terms of service](https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf).
  42. ```ini
  43. [server]
  44. PROTOCOL=https
  45. DOMAIN=git.example.com
  46. ENABLE_LETSENCRYPT=true
  47. LETSENCRYPT_ACCEPTTOS=true
  48. LETSENCRYPT_DIRECTORY=https
  49. LETSENCRYPT_EMAIL=email@example.com
  50. ```
  51. To learn more about the config values, please checkout the [Config Cheat Sheet](../config-cheat-sheet#server).
  52. ## Using reverse proxy
  53. Setup up your reverse proxy as shown in the [reverse proxy guide](../reverse-proxies).
  54. After that, enable HTTPS by following one of these guides:
  55. * [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html)
  56. * [apache2/httpd](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html)
  57. * [caddy](https://caddyserver.com/docs/tls)
  58. Note: Your connection between your reverse proxy and Gitea might be unencrypted. To encrypt it too, follow the [built-in server guide](#using-built-in-server) and change
  59. the proxy url to `https://[URL]`.