1
0
mirror of https://github.com/daniviga/bite.git synced 2024-11-23 05:16:13 +01:00
bite/docker/ingress/nginx.conf
Daniele Viganò be4c226955
Fix HTTP reverse proxy with embedded IoT (#20)
* Add an ENV far for custom docker binding

* Delay in Arduino can be customized

* Fix 400 error with Arduino telemetry and Nginx
This was caused by the client not waiting for a response.
Also Content-Length header was bogus.

* Do not crash mqtt-to-db if devices isn't proviosioned

* Update READMEs
2020-06-21 22:58:46 +02:00

85 lines
2.3 KiB
Nginx Configuration File

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;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
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;
}
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;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
keepalive_requests 10;
keepalive_timeout 60 60;
location / {
proxy_pass http://bite;
proxy_http_version 1.1;
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;
## !- This is mandatory for IoT that do not wait for a reply -! ##
proxy_ignore_client_abort on;
}
location /mqtt {
proxy_pass http://broker;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location /static/ {
root /srv/appdata/bite;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}