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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 you Apache HTTPD configuration (usually located at `/etc/apache2/httpd.conf` in Ubuntu):
  40. ```
  41. <VirtualHost *:80>
  42. ...
  43. ProxyPreserveHost On
  44. ProxyRequests off
  45. ProxyPass / http://localhost:3000/
  46. ProxyPassReverse / http://localhost:3000/
  47. </VirtualHost>
  48. ```
  49. Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`
  50. ## Using Apache HTTPD with a Sub-path as a reverse proxy
  51. 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):
  52. ```
  53. <VirtualHost *:80>
  54. ...
  55. <Proxy *>
  56. Order allow,deny
  57. Allow from all
  58. </Proxy>
  59. ProxyPass /git http://localhost:3000 # Note: no trailing slash after either /git or port
  60. ProxyPassReverse /git http://localhost:3000 # Note: no trailing slash after either /git or port
  61. </VirtualHost>
  62. ```
  63. Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.
  64. Note: The following Apache HTTPD mods must be enabled: `proxy`, `proxy_http`
  65. ## Using Caddy as a reverse proxy
  66. If you want Caddy to serve your Gitea instance you can add the following server block to your Caddyfile:
  67. ```
  68. git.example.com {
  69. proxy / http://localhost:3000
  70. }
  71. ```
  72. ## Using Caddy with a Sub-path as a reverse proxy
  73. 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 you server block in your Caddyfile:
  74. ```
  75. git.example.com {
  76. proxy /git/ http://localhost:3000 # Note: Trailing Slash after /git/
  77. }
  78. ```
  79. Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.