-
Notifications
You must be signed in to change notification settings - Fork 5
/
proxy.conf
76 lines (60 loc) · 1.78 KB
/
proxy.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# vim: set syntax=nginx ft=nginx
load_module modules/ngx_stream_js_module.so;
events { }
stream {
keyval_zone zone=demo:32k state=/var/lib/nginx/state/demo.keyval;
keyval "name" $demo_service zone=demo;
error_log /var/log/nginx/mqtt_error.log info; # NGINX JavaScript debug logging
map $demo_service $demo_loop {
clientid_cn_mod 127.0.0.1:8001;
properties_routing 127.0.0.1:8003;
default 127.0.0.1:8001;
}
map $demo_service $demo_loop_ssl {
clientid_cn_mod 127.0.0.1:8002;
properties_routing 127.0.0.1:8004;
default 127.0.0.1:8002;
}
# log format including clientid and username
js_var $clientid;
js_var $username;
log_format mqtt '$remote_addr $server_port [$time_local] $protocol $status $bytes_received '
'$bytes_sent $upstream_addr $clientid $username';
resolver 127.0.0.11 status_zone=docker_dns;
upstream mqtt_brokers {
zone mqtt 64k;
server broker:1883 resolve;
hash $clientid consistent;
}
match mqtt_conn {
# Send CONNECT packet with client ID "test"
send \x10\x14\x00\x04\x4d\x51\x54\x54\x05\x02\x00\x3c\x03\x21\x00\x14\x00\x04\x74\x65\x73\x74;
expect \x20\x13\x00\x00\x10\x27\x00\x10\x00\x00\x25\x01\x2a\x01\x29\x01\x22\xff\xff\x28\x01;
}
server {
listen 1883;
proxy_pass $demo_loop;
proxy_connect_timeout 1s;
proxy_timeout 5400s;
}
server {
listen 8883;
proxy_pass $demo_loop_ssl;
proxy_connect_timeout 1s;
proxy_timeout 5400s;
}
include stream.conf.d/*.conf;
}
http {
include /etc/nginx/mime.types;
server {
listen 80;
status_zone mgmt_traffic;
location /api {
api write=on;
}
location /dashboard.html {
root /usr/share/nginx/html;
}
}
}