2017-09-19 00:28:14 +02:00
|
|
|
#
|
2019-04-02 17:54:24 +02:00
|
|
|
# Copyright (c) 2018
|
|
|
|
# Mainflux
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
# This is the default Mainflux NGINX configuration.
|
2017-09-19 00:28:14 +02:00
|
|
|
|
|
|
|
user nginx;
|
|
|
|
worker_processes auto;
|
|
|
|
pid /run/nginx.pid;
|
|
|
|
include /etc/nginx/modules-enabled/*.conf;
|
|
|
|
|
|
|
|
events {
|
2018-03-11 18:06:01 +01:00
|
|
|
worker_connections 768;
|
2017-09-19 00:28:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
2018-03-11 18:06:01 +01:00
|
|
|
sendfile on;
|
|
|
|
tcp_nopush on;
|
|
|
|
tcp_nodelay on;
|
|
|
|
keepalive_timeout 65;
|
|
|
|
types_hash_max_size 2048;
|
|
|
|
|
|
|
|
include /etc/nginx/mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
2019-04-02 17:54:24 +02:00
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
2018-03-11 18:06:01 +01:00
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
|
|
|
|
access_log /var/log/nginx/access.log;
|
|
|
|
error_log /var/log/nginx/error.log;
|
2017-09-19 00:28:14 +02:00
|
|
|
|
|
|
|
server {
|
|
|
|
listen 80 default_server;
|
|
|
|
listen [::]:80 default_server;
|
|
|
|
listen 443 ssl http2 default_server;
|
|
|
|
listen [::]:443 ssl http2 default_server;
|
|
|
|
|
2019-04-02 17:54:24 +02:00
|
|
|
# These paths are set to its default values as
|
|
|
|
# a volume in the docker/docker-compose.yml file.
|
2017-09-19 00:28:14 +02:00
|
|
|
ssl_certificate /etc/ssl/certs/mainflux-server.crt;
|
|
|
|
ssl_certificate_key /etc/ssl/private/mainflux-server.key;
|
2017-09-21 18:50:00 +02:00
|
|
|
ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
2017-09-19 00:28:14 +02:00
|
|
|
|
2019-04-02 17:54:24 +02:00
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
2017-09-19 00:28:14 +02:00
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
|
|
|
|
ssl_ecdh_curve secp384r1;
|
|
|
|
ssl_session_tickets off;
|
2017-09-21 18:50:00 +02:00
|
|
|
ssl_stapling off;
|
2017-09-19 00:28:14 +02:00
|
|
|
ssl_stapling_verify on;
|
|
|
|
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
|
|
|
resolver_timeout 5s;
|
|
|
|
|
|
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
|
|
|
|
add_header X-Frame-Options DENY;
|
|
|
|
add_header X-Content-Type-Options nosniff;
|
2017-09-21 18:50:00 +02:00
|
|
|
add_header Access-Control-Allow-Origin '*';
|
|
|
|
add_header Access-Control-Allow-Methods '*';
|
2019-04-02 17:54:24 +02:00
|
|
|
add_header Access-Control-Allow-Headers '*';
|
2017-09-21 18:50:00 +02:00
|
|
|
|
|
|
|
server_name localhost;
|
2018-03-11 18:06:01 +01:00
|
|
|
|
2018-05-14 17:21:06 +02:00
|
|
|
# Proxy pass to users service
|
|
|
|
location ~ ^/(users|tokens) {
|
|
|
|
proxy_redirect off;
|
|
|
|
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;
|
2018-11-08 19:29:58 +01:00
|
|
|
proxy_pass http://users:8180;
|
2018-05-14 17:21:06 +02:00
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
}
|
2018-03-11 18:06:01 +01:00
|
|
|
|
2018-05-15 17:13:09 +02:00
|
|
|
# Proxy pass to things service
|
|
|
|
location ~ ^/(things|channels) {
|
2018-05-14 17:21:06 +02:00
|
|
|
proxy_redirect off;
|
|
|
|
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;
|
2018-05-24 15:26:03 +02:00
|
|
|
add_header Access-Control-Expose-Headers Location;
|
2018-11-08 19:29:58 +01:00
|
|
|
proxy_pass http://things:8182;
|
2018-05-14 17:21:06 +02:00
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
|
|
|
}
|
2017-09-21 18:50:00 +02:00
|
|
|
}
|
|
|
|
|
2018-05-28 19:20:17 +02:00
|
|
|
location /version {
|
|
|
|
proxy_redirect off;
|
|
|
|
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;
|
2018-11-08 19:29:58 +01:00
|
|
|
proxy_pass http://things:8182;
|
2018-05-28 19:20:17 +02:00
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-14 17:21:06 +02:00
|
|
|
# Proxy pass to mainflux-http-adapter
|
|
|
|
location /http/ {
|
|
|
|
proxy_redirect off;
|
|
|
|
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://http-adapter:8185/;
|
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
|
|
|
}
|
2018-05-14 13:11:29 +02:00
|
|
|
}
|
2017-09-19 00:28:14 +02:00
|
|
|
|
2018-05-14 17:21:06 +02:00
|
|
|
# Proxy pass to mainflux-ws-adapter
|
|
|
|
location /ws/ {
|
|
|
|
proxy_redirect off;
|
|
|
|
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_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "Upgrade";
|
|
|
|
proxy_connect_timeout 7d;
|
|
|
|
proxy_send_timeout 7d;
|
|
|
|
proxy_read_timeout 7d;
|
|
|
|
proxy_pass http://ws-adapter:8186/;
|
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
2018-05-14 13:11:29 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-02 17:54:24 +02:00
|
|
|
|
|
|
|
# Proxy pass to mainflux-mqtt-adapter over WS
|
2018-05-20 09:29:19 +02:00
|
|
|
location /mqtt {
|
|
|
|
proxy_redirect off;
|
|
|
|
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_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "Upgrade";
|
|
|
|
proxy_connect_timeout 7d;
|
|
|
|
proxy_send_timeout 7d;
|
|
|
|
proxy_read_timeout 7d;
|
|
|
|
proxy_pass http://mqtt-adapter:8880/;
|
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
}
|
2018-05-21 18:18:13 +02:00
|
|
|
|
|
|
|
location / {
|
|
|
|
proxy_redirect off;
|
|
|
|
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;
|
2019-03-06 16:21:09 +01:00
|
|
|
proxy_pass http://ui:3000/;
|
2018-05-21 18:18:13 +02:00
|
|
|
|
|
|
|
# Allow OPTIONS method CORS
|
|
|
|
if ($request_method = OPTIONS ) {
|
|
|
|
add_header Content-Length 0;
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
}
|
2018-05-20 09:29:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# MQTT
|
|
|
|
stream {
|
|
|
|
server {
|
|
|
|
listen 8883 ssl;
|
|
|
|
listen [::]:8883 ssl;
|
|
|
|
|
2019-04-02 17:54:24 +02:00
|
|
|
# These paths are set to its default values as
|
|
|
|
# a volume in the docker/docker-compose.yml file.
|
2018-05-20 09:29:19 +02:00
|
|
|
ssl_certificate /etc/ssl/certs/mainflux-server.crt;
|
|
|
|
ssl_certificate_key /etc/ssl/private/mainflux-server.key;
|
|
|
|
ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
|
|
|
|
2019-04-02 17:54:24 +02:00
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
2018-05-20 09:29:19 +02:00
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
|
|
|
|
ssl_ecdh_curve secp384r1;
|
|
|
|
ssl_session_tickets off;
|
|
|
|
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
|
|
|
resolver_timeout 5s;
|
2018-05-24 15:26:03 +02:00
|
|
|
|
2018-05-20 09:29:19 +02:00
|
|
|
proxy_pass mqtt-adapter:1883;
|
2017-09-19 00:28:14 +02:00
|
|
|
}
|
|
|
|
}
|