2020-06-21 23:34:54 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: syntax=nginx tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
#
|
|
|
|
# BITE - A Basic/IoT/Example
|
|
|
|
# Copyright (C) 2020 Daniele Viganò <daniele@vigano.me>
|
|
|
|
#
|
|
|
|
# BITE is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# BITE is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2020-06-18 00:02:28 +02:00
|
|
|
user nginx;
|
|
|
|
worker_processes auto;
|
|
|
|
|
|
|
|
error_log /dev/stdout warn;
|
|
|
|
pid /var/run/nginx.pid;
|
|
|
|
|
|
|
|
|
|
|
|
events {
|
|
|
|
worker_connections 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
http {
|
|
|
|
include /etc/nginx/mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
|
|
|
|
access_log /dev/stdout main;
|
|
|
|
|
|
|
|
sendfile on;
|
|
|
|
keepalive_timeout 65;
|
|
|
|
gzip off;
|
|
|
|
|
2020-06-21 15:21:00 +02:00
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
default upgrade;
|
|
|
|
'' close;
|
|
|
|
}
|
|
|
|
|
2020-06-18 00:02:28 +02:00
|
|
|
upstream bite {
|
|
|
|
# We point to the Docker 'service' instead of directly to the container
|
|
|
|
# Docker does then a DNS round-robin internally
|
|
|
|
server bite:8000;
|
|
|
|
}
|
|
|
|
|
2020-06-21 15:21:00 +02:00
|
|
|
upstream broker {
|
|
|
|
# We point to the Docker 'service' instead of directly to the container
|
|
|
|
# Docker does then a DNS round-robin internally
|
|
|
|
server broker:9001;
|
|
|
|
}
|
|
|
|
|
2020-06-18 00:02:28 +02:00
|
|
|
server {
|
|
|
|
listen 80 default_server;
|
|
|
|
listen [::]:80 default_server;
|
|
|
|
server_name _;
|
|
|
|
|
|
|
|
keepalive_requests 10;
|
|
|
|
keepalive_timeout 60 60;
|
|
|
|
|
|
|
|
location / {
|
|
|
|
proxy_pass http://bite;
|
2020-06-21 22:58:46 +02:00
|
|
|
proxy_http_version 1.1;
|
2020-06-18 00:02:28 +02:00
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-Host $host:$server_port;
|
|
|
|
proxy_set_header X-Forwarded-Server $host;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
|
|
|
proxy_read_timeout 300;
|
|
|
|
proxy_connect_timeout 300;
|
2020-06-21 22:58:46 +02:00
|
|
|
|
|
|
|
## !- This is mandatory for IoT that do not wait for a reply -! ##
|
|
|
|
proxy_ignore_client_abort on;
|
2020-06-18 00:02:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-21 15:21:00 +02:00
|
|
|
location /mqtt {
|
|
|
|
proxy_pass http://broker;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
}
|
|
|
|
|
2020-06-18 19:09:46 +02:00
|
|
|
location /static/ {
|
|
|
|
root /srv/appdata/bite;
|
|
|
|
}
|
|
|
|
|
2020-06-18 00:02:28 +02:00
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
location = /50x.html {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|