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.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. To use Gitea's built-in HTTPS support, you must change your `app.ini` file:
  20. ```ini
  21. [server]
  22. PROTOCOL=https
  23. ROOT_URL = `https://git.example.com:3000/`
  24. HTTP_PORT = 3000
  25. CERT_FILE = cert.pem
  26. KEY_FILE = key.pem
  27. ```
  28. To learn more about the config values, please checkout the [Config Cheat Sheet](../config-cheat-sheet#server).
  29. ### Setting up HTTP redirection
  30. 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:
  31. ```ini
  32. [server]
  33. REDIRECT_OTHER_PORT = true
  34. ; Port the redirection service should listen on
  35. PORT_TO_REDIRECT = 3080
  36. ```
  37. If you are using Docker, make sure that this port is configured in your `docker-compose.yml` file.
  38. ## Using Let's Encrypt
  39. [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.
  40. 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).
  41. ```ini
  42. [server]
  43. PROTOCOL=https
  44. DOMAIN=git.example.com
  45. ENABLE_LETSENCRYPT=true
  46. LETSENCRYPT_ACCEPTTOS=true
  47. LETSENCRYPT_DIRECTORY=https
  48. LETSENCRYPT_EMAIL=email@example.com
  49. ```
  50. To learn more about the config values, please checkout the [Config Cheat Sheet](../config-cheat-sheet#server).
  51. ## Using reverse proxy
  52. Setup up your reverse proxy as shown in the [reverse proxy guide](../reverse-proxies).
  53. After that, enable HTTPS by following one of these guides:
  54. * [nginx](https://nginx.org/en/docs/http/configuring_https_servers.html)
  55. * [apache2/httpd](https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html)
  56. * [caddy](https://caddyserver.com/docs/tls)
  57. 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
  58. the proxy url to `https://[URL]`.