-
Notifications
You must be signed in to change notification settings - Fork 64
/
nginx.conf
259 lines (220 loc) · 7.93 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
client_max_body_size 2G;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Add 10min timeout if we get stuck while processing something like docker images and firmware upload
proxy_read_timeout 600s;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Redirect legacy companion port (Companion 0.0.X) to our new homepage
server{
listen 2770;
location / {
rewrite ^/(.*)$ http://$host redirect;
}
}
server {
listen 80;
add_header Access-Control-Allow-Origin *;
# Endpoint used for backend status checks.
# It will always return an empty 204 response when online.
location /status {
return 204;
}
location /ardupilot-manager {
include cors.conf;
rewrite ^/ardupilot-manager$ /ardupilot-manager/ redirect;
rewrite ^/ardupilot-manager/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8000;
}
location /bag {
include cors.conf;
rewrite ^/bag$ /bag/ redirect;
rewrite ^/bag/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9101;
}
location /beacon {
include cors.conf;
rewrite ^/beacon$ /beacon/ redirect;
rewrite ^/beacon/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9111;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Interface-Ip $server_addr;
}
location /bridget {
include cors.conf;
rewrite ^/bridget$ /bridget/ redirect;
rewrite ^/bridget/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:27353;
}
location /cable-guy {
include cors.conf;
rewrite ^/cable-guy$ /cable-guy/ redirect;
rewrite ^/cable-guy/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9090;
}
location /commander {
include cors.conf;
rewrite ^/commander$ /commander/ redirect;
rewrite ^/commander/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9100;
}
location /docker {
limit_except GET {
deny all;
}
rewrite ^/docker$ /docker/ redirect;
rewrite ^/docker/(.*)$ /$1 break;
proxy_pass http://unix:/var/run/docker.sock:/;
}
location /file-browser {
rewrite ^/file-browser$ /file-browser/ redirect;
rewrite ^/file-browser/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:7777;
}
location /helper {
include cors.conf;
rewrite ^/helper$ /helper/ redirect;
rewrite ^/helper/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:81;
}
location /kraken {
include cors.conf;
rewrite ^/kraken$ /kraken/ redirect;
rewrite ^/kraken/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9134;
}
location /nmea-injector {
include cors.conf;
rewrite ^/nmea-injector$ /nmea-injector/ redirect;
rewrite ^/nmea-injector/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:2748;
}
location ^~ /logviewer {
# ^~ makes this a higher priority than locations with regex
expires 10d;
root /home/pi/tools;
}
location /mavlink2rest {
# Hide the header from the upstream application
proxy_hide_header Access-Control-Allow-Origin;
include cors.conf;
rewrite ^/mavlink2rest$ /mavlink2rest/ redirect;
rewrite ^/mavlink2rest/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:6040;
# next two lines are required for websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /mavlink-camera-manager {
include cors.conf;
rewrite ^/mavlink-camera-manager$ /mavlink-camera-manager/ redirect;
rewrite ^/mavlink-camera-manager/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:6020;
}
location /network-test {
include cors.conf;
rewrite ^/network-test$ /network-test/ redirect;
rewrite ^/network-test/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9120;
# next two lines are required for websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /system-information {
include cors.conf;
rewrite ^/system-information$ /system-information/ redirect;
rewrite ^/system-information/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:6030;
# next two lines are required for websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /terminal {
rewrite ^/terminal$ /terminal/ redirect;
rewrite ^/terminal/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8088;
# next two lines are required for websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /version-chooser {
include cors.conf;
rewrite ^/version-chooser$ /version-chooser/ redirect;
rewrite ^/version-chooser/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8081;
proxy_buffering off;
expires -1;
add_header Cache-Control no-store;
}
location /wifi-manager {
include cors.conf;
rewrite ^/wifi-manager$ /wifi-manager/ redirect;
rewrite ^/wifi-manager/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9000;
}
location /ping {
include cors.conf;
rewrite ^/ping$ /ping/ redirect;
rewrite ^/ping/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:9110;
}
location / {
root /home/pi/frontend;
try_files $uri $uri/ /index.html;
autoindex on;
# allow frontend to see files using json
autoindex_format json;
}
location /assets/ {
root /home/pi/frontend/assets;
autoindex on;
# allow frontend to see files using json
autoindex_format json;
expires 5d; # built files have a hash, so we shouldn't have issues with old cache
}
location ~ ^/upload(/.*)$ {
client_max_body_size 100M;
alias /usr/blueos$1;
# Change the access permissions of the uploaded file
dav_access group:rw all:r;
create_full_put_path on;
# Configure the allowed HTTP methods
dav_methods PUT DELETE MKCOL COPY MOVE;
}
location /userdata {
root /usr/blueos;
autoindex on;
# use json as it is easily consumed by the frontend
# users already have access through the file browser
autoindex_format json;
# disable cache to improve developer experience
# this should have very little impact for users
expires -1;
add_header Cache-Control no-store;
add_header Access-Control-Allow-Origin *;
}
# Helper to redirect services to their port
location ~ ^/redirect-port/(?<port>\d+) {
return 301 $scheme://$host:$port;
}
}
}