Skip to content

Commit 36e661e

Browse files
committed
[docs] reverse-proxy: nginx: add two setups for STATIC_URL_PREFIX
Signed-off-by: Jakob Ackermann <[email protected]>
1 parent 4b1e3d8 commit 36e661e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

docs/content/doc/usage/reverse-proxies.en-us.md

+68
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,74 @@ server {
4444

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

47+
## Using Nginx as a reverse proxy and serve static resources directly
48+
We can tune the performance in splitting requests into categories static and dynamic.
49+
50+
CSS files, JavaScript files, images and web fonts are static content.
51+
The front page, a repository view or issue list is dynamic content.
52+
53+
Nginx can serve static resources directly and proxy only the dynamic requests to gitea.
54+
Nginx is optimized for serving static content, while the proxying of large responses might be the opposite of that
55+
(see https://serverfault.com/q/587386).
56+
57+
Download a snap shot of the gitea source repository to `/path/to/gitea/`.
58+
59+
We are only interested in the `public/` directory and you can delete the rest.
60+
61+
Depending on the scale of your user base, you might want to split the traffic to two distinct servers,
62+
or use a cdn for the static files.
63+
64+
### using a single node and a single domain
65+
66+
Set `[server] STATIC_URL_PREFIX = /_/static` in your configuration.
67+
68+
```
69+
server {
70+
listen 80;
71+
server_name git.example.com;
72+
73+
location /_/static {
74+
alias /path/to/gitea/public;
75+
}
76+
77+
location / {
78+
proxy_pass http://localhost:3000;
79+
}
80+
}
81+
```
82+
83+
### using two nodes and two domains
84+
85+
Set `[server] STATIC_URL_PREFIX = http://cdn.example.com/gitea` in your configuration.
86+
87+
```
88+
# application server running gitea
89+
server {
90+
listen 80;
91+
server_name git.example.com;
92+
93+
location / {
94+
proxy_pass http://localhost:3000;
95+
}
96+
}
97+
```
98+
99+
```
100+
# static content delivery server
101+
server {
102+
listen 80;
103+
server_name cdn.example.com;
104+
105+
location /gitea {
106+
alias /path/to/gitea/public;
107+
}
108+
109+
location / {
110+
return 404;
111+
}
112+
}
113+
```
114+
47115
## Using Apache HTTPD as a reverse proxy
48116

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

0 commit comments

Comments
 (0)