-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnginx.conf
61 lines (50 loc) · 1.61 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
worker_processes 5; ## Default: 1
worker_rlimit_nofile 8192;
events {
worker_connections 4096; ## Default: 1024
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 5555 default_server;
server_name _; # This is just an invalid value which will never trigger on a real hostname.
root /usr/share/nginx/html;
error_page 404 @404_fallback;
index index.html;
gzip on;
# Recommended GZIP settings from GCP documentation.
# https://cloud.google.com/load-balancing/docs/https/troubleshooting-ext-https-lbs#compression-not-working
gzip_vary on;
gzip_proxied any;
if ($host ~* ^www\.(.*)$) {
set $non_www_host $1;
return 301 $scheme://$non_www_host$request_uri;
}
# Serve static files and handle missing files in '/public' with SPA fallback
location /public {
try_files $uri =404;
gzip_types application/javascript text/css image/png image/svg+xml;
access_log off;
}
# Serve SPA
# Matches /features/featureId, but not /features/featureId/something
location ~ ^/features/[^/]+$ {
try_files $uri $uri/ /index.html;
}
location = /stats {
try_files $uri $uri/ /index.html;
}
location = / {
try_files $uri $uri/ =404;
}
# Named location to serve as the logic for the fallback
location @404_fallback {
try_files $uri /index.html;
}
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
}
}