Skip to content

Commit

Permalink
[docs] reverse-proxy: nginx: add two setups for STATIC_URL_PREFIX
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
  • Loading branch information
das7pad committed Aug 28, 2019
1 parent 4b1e3d8 commit 36e661e
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions docs/content/doc/usage/reverse-proxies.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,74 @@ server {

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

## Using Nginx as a reverse proxy and serve static resources directly
We can tune the performance in splitting requests into categories static and dynamic.

CSS files, JavaScript files, images and web fonts are static content.
The front page, a repository view or issue list is dynamic content.

Nginx can serve static resources directly and proxy only the dynamic requests to gitea.
Nginx is optimized for serving static content, while the proxying of large responses might be the opposite of that
(see https://serverfault.com/q/587386).

Download a snap shot of the gitea source repository to `/path/to/gitea/`.

We are only interested in the `public/` directory and you can delete the rest.

Depending on the scale of your user base, you might want to split the traffic to two distinct servers,
or use a cdn for the static files.

### using a single node and a single domain

Set `[server] STATIC_URL_PREFIX = /_/static` in your configuration.

```
server {
listen 80;
server_name git.example.com;
location /_/static {
alias /path/to/gitea/public;
}
location / {
proxy_pass http://localhost:3000;
}
}
```

### using two nodes and two domains

Set `[server] STATIC_URL_PREFIX = http://cdn.example.com/gitea` in your configuration.

```
# application server running gitea
server {
listen 80;
server_name git.example.com;
location / {
proxy_pass http://localhost:3000;
}
}
```

```
# static content delivery server
server {
listen 80;
server_name cdn.example.com;
location /gitea {
alias /path/to/gitea/public;
}
location / {
return 404;
}
}
```

## Using Apache HTTPD as a reverse proxy

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

0 comments on commit 36e661e

Please sign in to comment.