summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorJakob Ackermann <das7pad@outlook.com>2019-10-22 14:11:01 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2019-10-22 20:11:01 +0800
commit00629fea95970e99ba5ef05954bbad0804805df6 (patch)
tree1590e0f7913c71689727cc17a3bf2786b43028ce /docs
parentd0c7a08d751bd068e557efe56683b999d29eb910 (diff)
downloadgitea-00629fea95970e99ba5ef05954bbad0804805df6.tar.gz
gitea-00629fea95970e99ba5ef05954bbad0804805df6.zip
[assets] configurable URL for static resources (#7911)
* static url * add cors support for static resources * [assets] work on the migration to configurable url for assets Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [misc] fix whitespace Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [assets] fix the loading of the manifest.json It is generated dynamically, and as such can not be served by the cdn. Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * Revert "add cors support for static resources" This reverts commit 42f964fd181dbb8b139808b9be623470d4f0e40f Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [docs] add the STATIC_URL_PREFIX option Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [docs] reverse-proxy: nginx: add two setups for STATIC_URL_PREFIX Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [assets] migrate the url of a new asset to the static url prefix REF: f2a3abc683ad4b2177b7c7c6160a2c0b4316120a Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/content/doc/advanced/config-cheat-sheet.en-us.md7
-rw-r--r--docs/content/doc/usage/reverse-proxies.en-us.md68
2 files changed, 75 insertions, 0 deletions
diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
index f99e9f661a..c2744b2958 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
@@ -138,6 +138,13 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
Overwrite the automatically generated public URL.
This is useful if the internal and the external URL don't match (e.g. in Docker).
+- `STATIC_URL_PREFIX`: **\<empty\>**:
+ Overwrite this option to request static resources from a different URL.
+ This includes CSS files, images, JS files and web fonts.
+ Avatar images are dynamic resources and still served by gitea.
+ The option can be just a different path, as in `/static`, or another domain, as in `https://cdn.example.com`.
+ Requests are then made as `%(ROOT_URL)s/static/css/index.css` and `https://cdn.example.com/css/index.css` respective.
+ The static files are located in the `public/` directory of the gitea source repository.
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
diff --git a/docs/content/doc/usage/reverse-proxies.en-us.md b/docs/content/doc/usage/reverse-proxies.en-us.md
index 47a5b95572..55c8bb9710 100644
--- a/docs/content/doc/usage/reverse-proxies.en-us.md
+++ b/docs/content/doc/usage/reverse-proxies.en-us.md
@@ -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):