-
Notifications
You must be signed in to change notification settings - Fork 5
/
nginx.example.conf
70 lines (55 loc) · 1.78 KB
/
nginx.example.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
### GMCServer
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream gmcserver {
# Replace this address and port accoring to your GMCServer config
server 127.0.0.1:8000;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/myawesomedomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myawesomedomain.com/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
root /var/www/html/gmcserver;
index index.html;
server_name myawesomedomain.com;
# Root for webapp
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a index cause routing.
try_files $uri $uri/ /index.html;
}
# Root for API
location /api/v1/ {
proxy_pass http://gmcserver$request_uri;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Routes for websockets; needs special headers
location ~ /api/v1/device/[a-fA-F0-9]+/live {
proxy_pass http://gmcserver$uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_read_timeout 3m;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}
}
### GMCServer logging
# We need to force-enable http only connections because GMC Geiger counters do not support https
server {
listen 80;
listen [::]:80;
server_name gmc.vinceh121.me;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location / {
return 301 https://$host$request_uri;
}
location ~ (/api/v1/)?(log(2)?(\.asp)?|radmon\.php|measurements\.json) {
proxy_pass http://gmcserver$request_uri;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}