mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-28 13:48:49 +08:00
NOISSUE - Add MQTT to kubernetes nginx (#293)
* Fix nginx configuration for kubernetes Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Add dashflux to nginx configuration Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update kubernetes documentation Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Update soft links paths to relative Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
This commit is contained in:
parent
f0cbc47ee6
commit
3d134d52a6
@ -214,6 +214,22 @@ http {
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
proxy_pass http://dashflux:3000/;
|
||||
|
||||
# Allow OPTIONS method CORS
|
||||
if ($request_method = OPTIONS ) {
|
||||
add_header Content-Length 0;
|
||||
add_header Content-Type text/plain;
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,18 +33,18 @@ kubectl create -f k8s/mainflux/users-postgres.yml
|
||||
kubectl create -f k8s/mainflux/users.yml
|
||||
```
|
||||
|
||||
### 3. Setup Clients service
|
||||
### 3. Setup Things service
|
||||
|
||||
- Deploy PostgreSQL service for Clients service to use:
|
||||
- Deploy PostgreSQL service for Things service to use:
|
||||
|
||||
```
|
||||
kubectl create -f k8s/mainflux/clients-postgres.yml
|
||||
kubectl create -f k8s/mainflux/things-postgres.yml
|
||||
```
|
||||
|
||||
- Deploy Clients service:
|
||||
- Deploy Things service:
|
||||
|
||||
```
|
||||
kubectl create -f k8s/mainflux/clients.yml
|
||||
kubectl create -f k8s/mainflux/things.yml
|
||||
```
|
||||
|
||||
### 4. Setup Normalizer service
|
||||
@ -76,13 +76,13 @@ kubectl create -f k8s/mainflux/dashflux.yml
|
||||
- Create TLS server side certificate and keys:
|
||||
|
||||
```
|
||||
kubectl create secret tls mainflux-secret --key k8s/nginx/certs/mainflux-server.key --cert k8s/nginx/certs/mainflux-server.crt
|
||||
kubectl create secret generic mainflux-secret --from-file=k8s/nginx/ssl/certs/mainflux-server.crt --from-file=k8s/nginx/ssl/certs/mainflux-server.key --from-file=k8s/nginx/ssl/dhparam.pem
|
||||
```
|
||||
|
||||
- Create Kubernetes configmap to store NginX configuration:
|
||||
|
||||
```
|
||||
kubectl create configmap mainflux-nginx-config --from-file=k8s/nginx/default.conf
|
||||
kubectl create configmap mainflux-nginx-config --from-file=k8s/nginx/nginx.conf
|
||||
```
|
||||
|
||||
- Deploy NginX service:
|
||||
|
@ -1,30 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIFFTCCA/2gAwIBAgIJAPtBp1R03oQDMA0GCSqGSIb3DQEBDQUAMFcxEjAQBgNV
|
||||
BAMMCWxvY2FsaG9zdDERMA8GA1UECgwITWFpbmZsdXgxDDAKBgNVBAsMA0lvVDEg
|
||||
MB4GCSqGSIb3DQEJARYRaW5mb0BtYWluZmx1eC5jb20wHhcNMTcwMTA3MDA1NTIw
|
||||
WhcNMzIwMTA0MDA1NTIwWjBdMRgwFgYDVQQDDA9tYWluZmx1eC1zZXJ2ZXIxETAP
|
||||
BgNVBAoMCE1haW5mbHV4MQwwCgYDVQQLDANJb1QxIDAeBgkqhkiG9w0BCQEWEWlu
|
||||
Zm9AbWFpbmZsdXguY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
||||
mGShbFfHhE/Q/CvVgpfas9o2B2H4E1nrDSmQXqwUPJ2U5+ExqpPkM/xX77yC9gut
|
||||
k0RrM3fhB5AET9GnGMyFFlNYNPnWZOS6iQN2u5dg02TRqKdIhZZhs438u2wSRVwg
|
||||
oAqYyiVpoV3QFa2B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
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
#tcp_nopush on;
|
||||
#tcp_nodelay on;
|
||||
#keepalive_timeout 65;
|
||||
#types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
#include /etc/nginx/mime.types;
|
||||
#default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
upstream k8s-users {
|
||||
server users:8180;
|
||||
}
|
||||
|
||||
upstream k8s-things {
|
||||
server things:8182;
|
||||
}
|
||||
|
||||
upstream k8s-http {
|
||||
server http-adapter:8185;
|
||||
}
|
||||
|
||||
upstream k8s-ws {
|
||||
server ws-adapter:8186;
|
||||
}
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
# HTTP
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name mainflux-iot.ha.rs;
|
||||
access_log off;
|
||||
error_log off;
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
# HTTPS
|
||||
server {
|
||||
# SSL configuration
|
||||
listen 443 ssl http2 default_server;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
|
||||
#
|
||||
# Note: You should disable gzip for SSL traffic.
|
||||
# See: https://bugs.debian.org/773332
|
||||
#
|
||||
# Read up on ssl_ciphers to ensure a secure configuration.
|
||||
# See: https://bugs.debian.org/765782
|
||||
#
|
||||
# Self signed certs generated by the ssl-cert package
|
||||
# Don't use them in a production server!
|
||||
|
||||
# Certificates
|
||||
ssl_certificate /etc/nginx/ssl/tls.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/tls.key;
|
||||
|
||||
# from https://cipherli.st/
|
||||
# and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
|
||||
ssl_ecdh_curve secp384r1;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling off;
|
||||
ssl_stapling_verify on;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=300s;
|
||||
resolver_timeout 5s;
|
||||
|
||||
# Disable preloading HSTS for now. You can use the commented out header line that includes
|
||||
# the "preload" directive if you understand the implications.
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
|
||||
add_header X-Frame-Options DENY;
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Access-Control-Allow-Origin '*';
|
||||
add_header Access-Control-Allow-Methods '*';
|
||||
add_header Access-Control-Allow-Headers "*";
|
||||
|
||||
server_name mainflux-iot.ha.rs;
|
||||
|
||||
# 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;
|
||||
proxy_pass http://users:8180;
|
||||
|
||||
# Allow OPTIONS method CORS
|
||||
if ($request_method = OPTIONS ) {
|
||||
add_header Content-Length 0;
|
||||
add_header Content-Type text/plain;
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
||||
# Proxy pass to things service
|
||||
location ~ ^/(things|channels) {
|
||||
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://things:8182;
|
||||
|
||||
# Allow OPTIONS method CORS
|
||||
if ($request_method = OPTIONS ) {
|
||||
add_header Content-Length 0;
|
||||
add_header Content-Type text/plain;
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
||||
# 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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
proxy_pass http://dashflux:3000/;
|
||||
|
||||
# Allow OPTIONS method CORS
|
||||
if ($request_method = OPTIONS ) {
|
||||
add_header Content-Length 0;
|
||||
add_header Content-Type text/plain;
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
}
|
1
k8s/nginx/nginx.conf
Symbolic link
1
k8s/nginx/nginx.conf
Symbolic link
@ -0,0 +1 @@
|
||||
../../docker/nginx.conf
|
@ -11,6 +11,8 @@ spec:
|
||||
name: http
|
||||
- port: 443
|
||||
name: https
|
||||
- port: 8883
|
||||
name: mqtt
|
||||
selector:
|
||||
app: nginx
|
||||
---
|
||||
@ -32,13 +34,22 @@ spec:
|
||||
configMap:
|
||||
name: mainflux-nginx-config
|
||||
containers:
|
||||
- name: maiflux-nginx
|
||||
image: nginx:1.14-alpine
|
||||
- name: mainflux-nginx
|
||||
image: nginx:1.13-alpine
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- containerPort: 443
|
||||
- containerPort: 8883
|
||||
volumeMounts:
|
||||
- mountPath: /etc/nginx/ssl
|
||||
- mountPath: /etc/ssl/certs/mainflux-server.crt
|
||||
name: secret-volume
|
||||
- mountPath: /etc/nginx/conf.d
|
||||
subPath: mainflux-server.crt
|
||||
- mountPath: /etc/ssl/private/mainflux-server.key
|
||||
name: secret-volume
|
||||
subPath: mainflux-server.key
|
||||
- mountPath: /etc/ssl/certs/dhparam.pem
|
||||
name: secret-volume
|
||||
subPath: dhparam.pem
|
||||
- mountPath: /etc/nginx/nginx.conf
|
||||
name: configmap-volume
|
||||
subPath: nginx.conf
|
||||
|
1
k8s/nginx/ssl
Symbolic link
1
k8s/nginx/ssl
Symbolic link
@ -0,0 +1 @@
|
||||
../../docker/ssl
|
Loading…
x
Reference in New Issue
Block a user