This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
nginx.conf
74 lines (56 loc) · 2.04 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
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.
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 ~ index\.(physics|chemistry|biology)\.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 / {
# Everything else.
# 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:
if ($http_host ~ physics|8000) {
rewrite .* /index.physics.html last;
}
if ($http_host ~ chemistry|8001) {
rewrite .* /index.chemistry.html last;
}
if ($http_host ~ biology|8002) {
rewrite .* /index.biology.html last;
}
}
}
}