-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvr-nginx.conf
64 lines (56 loc) · 2.12 KB
/
nvr-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
# Sample nginx config file for integrating Moonglass into a Moonfire NVR installtion.
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}
# Proxied application IP and port(s)
upstream NVR_upstream {
server 127.0.0.1:8080;
keepalive 64;
}
server {
# change this to the hostname you will use to access the NVR
server_name nvr.example.com www.nvr.example.com;
# The port to use.
listen 80;
# Statically served pages
location ~ ^/(images/|fonts/|css/|favicons/|index.html|robots.txt|humans.txt|moonglass-webapp) {
# Change this to the location of the files you copied from the moonglass build.
root /home/ubuntu/moonglass;
access_log off;
expires max;
}
# NVR Api
location ~ ^/api {
proxy_pass http://NVR_upstream;
# Simple requests
if ($request_method ~* "(GET|POST)") {
add_header "Access-Control-Allow-Origin" *;
}
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
return 204;
}
}
proxy_redirect off;
proxy_intercept_errors on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
access_log on;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
}