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.

reverse-proxies.en-us.md 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ---
  2. date: "2018-05-22T11:00:00+00:00"
  3. title: "Usage: Reverse Proxies"
  4. slug: "reverse-proxies"
  5. weight: 17
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "usage"
  11. name: "Reverse Proxies"
  12. weight: 16
  13. identifier: "reverse-proxies"
  14. ---
  15. ## Using Nginx as a reverse proxy
  16. If you want Nginx to serve your Gitea instance, you can the following `server` section inside the `http` section of `nginx.conf`:
  17. ```
  18. server {
  19. listen 80;
  20. server_name git.example.com;
  21. location / {
  22. proxy_pass http://localhost:3000;
  23. }
  24. }
  25. ```
  26. ## Using Nginx with a sub-path as a reverse proxy
  27. In case you already have a site, and you want Gitea to share the domain name, you can setup Nginx to serve Gitea under a sub-path by adding the following `server` section inside the `http` section of `nginx.conf`:
  28. ```
  29. server {
  30. listen 80;
  31. server_name git.example.com;
  32. location /git/ { # Note: Trailing slash
  33. proxy_pass http://localhost:3000/; # Note: Trailing slash
  34. }
  35. }
  36. ```
  37. Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.
  38. ## Using Apache HTTPD as a reverse proxy
  39. If you want Apache HTTPD to serve your Gitea instance, you can add the following to your Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu):
  40. ```
  41. <VirtualHost *:80>
  42. ...
  43. ProxyPreserveHost On
  44. ProxyRequests off
  45. AllowEncodedSlashes NoDecode
  46. ProxyPass / http://localhost:3000/ nocanon
  47. ProxyPassReverse / http://localhost:3000/
  48. </VirtualHost>
  49. ```
  50. Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`
  51. ## Using Apache HTTPD with a sub-path as a reverse proxy
  52. In case you already have a site, and you want Gitea to share the domain name, you can setup Apache HTTPD to serve Gitea under a sub-path by adding the following to you Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu):
  53. ```
  54. <VirtualHost *:80>
  55. ...
  56. <Proxy *>
  57. Order allow,deny
  58. Allow from all
  59. </Proxy>
  60. AllowEncodedSlashes NoDecode
  61. # Note: no trailing slash after either /git or port
  62. ProxyPass /git http://localhost:3000 nocanon
  63. ProxyPassReverse /git http://localhost:3000
  64. </VirtualHost>
  65. ```
  66. Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.
  67. Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`
  68. ## Using Caddy as a reverse proxy
  69. If you want Caddy to serve your Gitea instance, you can add the following server block to your Caddyfile:
  70. ```
  71. git.example.com {
  72. proxy / http://localhost:3000
  73. }
  74. ```
  75. ## Using Caddy with a sub-path as a reverse proxy
  76. In case you already have a site, and you want Gitea to share the domain name, you can setup Caddy to serve Gitea under a sub-path by adding the following to your server block in your Caddyfile:
  77. ```
  78. git.example.com {
  79. proxy /git/ http://localhost:3000 # Note: Trailing Slash after /git/
  80. }
  81. ```
  82. Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.