client/nginx: minor tweaks to nginx config
This commit is contained in:
parent
54eab0aa35
commit
fa3b6275b3
1 changed files with 36 additions and 5 deletions
|
@ -15,10 +15,9 @@ http {
|
||||||
log_format main '$remote_addr -> $request [$status] - '
|
log_format main '$remote_addr -> $request [$status] - '
|
||||||
'referer: $http_referer $http_x_forwarded_for';
|
'referer: $http_referer $http_x_forwarded_for';
|
||||||
access_log /dev/stdout main;
|
access_log /dev/stdout main;
|
||||||
|
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
sendfile on;
|
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
client_max_body_size 0;
|
|
||||||
|
|
||||||
upstream backend {
|
upstream backend {
|
||||||
server __BACKEND__:6666;
|
server __BACKEND__:6666;
|
||||||
|
@ -32,6 +31,8 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/api/(.*)$ {
|
location ~ ^/api/(.*)$ {
|
||||||
|
tcp_nodelay on;
|
||||||
|
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
if ($request_method = 'OPTIONS') {
|
if ($request_method = 'OPTIONS') {
|
||||||
add_header 'Access-Control-Allow-Methods'
|
add_header 'Access-Control-Allow-Methods'
|
||||||
|
@ -41,29 +42,59 @@ http {
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request_uri ~* "/api/(.*)") {
|
client_max_body_size 0;
|
||||||
proxy_pass http://backend/$1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_comp_level 3;
|
gzip_comp_level 3;
|
||||||
gzip_min_length 20;
|
gzip_min_length 20;
|
||||||
gzip_proxied expired no-cache no-store private auth;
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
gzip_types text/plain application/json;
|
gzip_types text/plain application/json;
|
||||||
|
|
||||||
|
if ($request_uri ~* "/api/(.*)") {
|
||||||
|
proxy_pass http://backend/$1;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 @badproxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /data/ {
|
location /data/ {
|
||||||
rewrite ^/data/(.*) /$1 break;
|
rewrite ^/data/(.*) /$1 break;
|
||||||
root /data;
|
root /data;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
|
||||||
|
error_page 403 @unauthorized;
|
||||||
|
error_page 404 @notfound;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /var/www;
|
root /var/www;
|
||||||
try_files $uri /index.htm;
|
try_files $uri /index.htm;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
|
||||||
gzip_static on;
|
gzip_static on;
|
||||||
gzip_proxied expired no-cache no-store private auth;
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location @unauthorized {
|
||||||
|
return 403 "Unauthorized";
|
||||||
|
default_type text/plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
location @notfound {
|
||||||
|
return 404 "Not Found";
|
||||||
|
default_type text/plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
location @badproxy {
|
||||||
|
return 502 "Failed to connect to szurubooru REST API";
|
||||||
|
default_type text/plain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue