This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
91 lines (70 loc) · 2.67 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
user nginx;
worker_processes auto;
error_log /dev/stdout error;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '[$time_local] $status "$http_x_forwarded_for" "$request"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
# Do not use etags for caching:
etag off;
# Last-Modified is always added anyway.
# Configure User-Agents considered unsupported:
map $http_user_agent $unsupported_browser {
default 0;
# Consider IE11 and older unsupported:
"~Trident/" 1;
# Consider Safari <= 9 as unsupported:
"~Mac OS.*AppleWebKit.*Version/[0-9]\..*Safari" 1;
# Consider Safari 10 unsupported:
"~Mac OS.*AppleWebKit.*Version/10\..*Safari" 1;
}
server {
listen 80;
server_name localhost;
error_log /var/log/nginx/error.log;
root /usr/share/nginx/html;
location /assets {
# Strongly cache these things for at least 30 days:
add_header Cache-Control "public, max-age=2592000, no-transform";
try_files $uri @default;
}
location /static {
# Maybe also strongly cache these things for at least 30 days?
add_header Cache-Control "public, max-age=2592000, no-transform";
try_files $uri @default;
}
location /index.html {
# Index pages, and also serves unknown URLs too from @default.
# Do not allow caching of these index pages at all:
add_header Cache-Control "no-cache, no-store, must-revalidate";
try_files $uri @default;
}
location ~ ^/unsupported_browser.(html|js)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
try_files $uri @default;
}
location / {
# Everything else.
if ($unsupported_browser) {
rewrite .* /unsupported_browser.html;
}
# Allow caching, but require revalidation every time:
add_header Cache-Control "no-cache, must-revalidate";
try_files $uri @default;
}
location @default {
# Unknown files not found by any of the try_files above.
# No headers can be added in this block, since they won't be used.
# Rewrite all unknown requests to the relevant index page:
rewrite .* /index.html last;
}
}
}