211 lines
6.2 KiB
Plaintext
Executable File
211 lines
6.2 KiB
Plaintext
Executable File
# Upstream server for handling API call
|
|
upstream agmission_server {
|
|
server 127.0.0.1:7000;
|
|
}
|
|
|
|
upstream track_server {
|
|
server 127.0.0.1:6100;
|
|
}
|
|
|
|
upstream track_server_secure {
|
|
server 127.0.0.1:6101;
|
|
}
|
|
|
|
# Expires map: defines the mapping between the file type and how long that kind of file should be cached
|
|
map $sent_http_content_type $expires {
|
|
default off;
|
|
text/html epoch; #means no cache, as it is not a static page
|
|
text/css modified;
|
|
application/javascript modified;
|
|
application/woff2 max;
|
|
}
|
|
# ~image/ 30d; #it is only the logo, so maybe I could change it once a month now
|
|
|
|
# Default server configuration
|
|
#
|
|
server {
|
|
# SSL config
|
|
listen *:443 ssl http2 default_server;
|
|
listen [::]:443 ssl http2;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/nginx/ssl/agm-bundle.crt;
|
|
ssl_certificate_key /etc/nginx/ssl/agm-server.key;
|
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
|
|
|
http2_max_field_size 64k;
|
|
http2_max_header_size 512k;
|
|
|
|
server_name agmission.agnav.com;
|
|
|
|
root /media/ssd1/agmission/dist;
|
|
|
|
index index.html index.htm;
|
|
|
|
expires $expires;
|
|
|
|
location / {
|
|
# First attempt to serve request as file, then
|
|
# as directory, then fall back to index.html.
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /reports/ {
|
|
# 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 200;
|
|
}
|
|
alias /media/ssd1/agmission/reports/;
|
|
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
|
|
location /public/ {
|
|
alias /media/ssd1/agmission/public/;
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
location /leaflet/ {
|
|
alias /media/ssd1/agmission/node_modules/leaflet/dist/;
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
location /esri-leaflet/ {
|
|
alias /media/ssd1/agmission/node_modules/esri-leaflet/dist/;
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
location /api/ {
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
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_pass http://agmission_server/api/;
|
|
}
|
|
|
|
location = /track/stream {
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection '';
|
|
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
chunked_transfer_encoding off;
|
|
proxy_read_timeout 12h;
|
|
|
|
proxy_set_header Host $host;
|
|
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 content-type "application/json";
|
|
|
|
proxy_pass https://track_server_secure/track/stream;
|
|
# access_log /home/trung/temp/logs.txt;
|
|
}
|
|
|
|
|
|
location /track/ {
|
|
#proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
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_pass http://track_server/track/;
|
|
}
|
|
|
|
|
|
location /forecast/ {
|
|
proxy_http_version 1.1; // Must be explicit ver 1.1, Darksky upstream server
|
|
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_pass https://api.darksky.net/forecast/;
|
|
|
|
#proxy_redirect off;
|
|
}
|
|
|
|
|
|
location /gmapapi/ {
|
|
|
|
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_pass https://maps.googleapis.com/maps/api/;
|
|
|
|
#proxy_redirect off;
|
|
}
|
|
|
|
location /report/ {
|
|
return 301 http://$host$request_uri;
|
|
}
|
|
|
|
# deny access to .htaccess files, if Apache's document root
|
|
# concurs with nginx's one
|
|
#
|
|
#location ~ /\.ht {
|
|
# deny all;
|
|
#}
|
|
}
|
|
|
|
server {
|
|
listen *:80 default_server;
|
|
|
|
# Migrate legacy TrackerNav API to current with these route proxies
|
|
location = /api/v1/tracks {
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
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_pass http://track_server/track/tracks;
|
|
}
|
|
|
|
location = /api/v1/auth/login {
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
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_pass http://agmission_server/api/users/login;
|
|
}
|
|
|
|
|
|
location / { # the default location redirects to https
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
location /report/ {
|
|
# 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 200;
|
|
}
|
|
|
|
root /media/ssd1/agmission/.tmp;
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
}
|
|
|