Using Nginx as a reverse proxy

If you want Nginx to serve your Gitea instance you can the following server section inside the http section of nginx.conf:

  1. server {
  2. listen 80;
  3. server_name git.example.com;
  4. location / {
  5. proxy_pass http://localhost:3000;
  6. }
  7. }

Using Nginx with a Sub-path as a reverse proxy

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:

  1. server {
  2. listen 80;
  3. server_name git.example.com;
  4. location /git/ { # Note: Trailing slash
  5. proxy_pass http://localhost:3000/; # Note: Trailing slash
  6. }
  7. }

Then set [server] ROOT_URL = http://git.example.com/git/ in your configuration.

Using Apache HTTPD as a reverse proxy

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):

  1. <VirtualHost *:80>
  2. ...
  3. ProxyPreserveHost On
  4. ProxyRequests off
  5. ProxyPass / http://localhost:3000/
  6. ProxyPassReverse / http://localhost:3000/
  7. </VirtualHost>

Note: The following Apache HTTPD mods must be enabled: proxy, proxy_http

Using Apache HTTPD with a Sub-path as a reverse proxy

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):

  1. <VirtualHost *:80>
  2. ...
  3. <Proxy *>
  4. Order allow,deny
  5. Allow from all
  6. </Proxy>
  7. ProxyPass /git http://localhost:3000 # Note: no trailing slash after either /git or port
  8. ProxyPassReverse /git http://localhost:3000 # Note: no trailing slash after either /git or port
  9. </VirtualHost>

Then set [server] ROOT_URL = http://git.example.com/git/ in your configuration.

Note: The following Apache HTTPD mods must be enabled: proxy, proxy_http

Using Caddy with a Sub-path as a reverse proxy

If you want Caddy to serve your Gitea instance you can add the following server block to your Caddyfile:

  1. git.example.com {
  2. proxy / http://localhost:3000
  3. }

Using Caddy with a Sub-path as a reverse proxy

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:

  1. git.example.com {
  2. proxy /git/ http://localhost:3000 # Note: Trailing Slash after /git/
  3. }

Then set [server] ROOT_URL = http://git.example.com/git/ in your configuration.

原文: https://docs.gitea.io/zh-cn/reverse-proxies/