-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
103 lines (81 loc) · 3.21 KB
/
nginx.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#user nobody;
worker_processes 54444;
error_log /tmp/openresty_error.log ;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
## DNS local pour pointer sur utiliser /etc/hosts : systemd-resolved.service
# memoire cache intern Nginx sur 60 secondes
resolver 127.0.0.53 valid=6s;
log_format main '$remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_x_forwarded_for"';
error_log /home/actemium/Applications/reverseproxy/log/error.log ;
access_log /home/actemium/Applications/reverseproxy/log/acces.log main;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
init_by_lua_block {
jit.opt.start("minstitch=10")
}
########################################################################
# Serveur Ocpp SOAP 1.5 : port 6060, redirect to http://{CBI}:6060/ocpp
# ip=CBI ==> resolved with DDNS en localhost
# DDNS mise a jour par cruncher Saiave ( log_ddns.rb )
########################################################################
server {
listen 6060;
server_name OcppSoapBackEndRP ;
keepalive_timeout 25;
location / {
default_type text/html;
lua_need_request_body on;
client_max_body_size 10k;
client_body_buffer_size 10k;
set $proxy "unknown0";
rewrite_by_lua_block {
ngx.req.read_body()
ngx.var.proxy = "unknown1"
local match = ngx.re.match(ngx.var.request_body,"chargeBoxIdentity[^>]*>([^<]*)<")
if match then
ngx.var.proxy = match[1]
end
}
proxy_pass http://$proxy:6060/ocpp;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
########################################################################
# WebSocket server
#
# Le CBI est le dernier mot du path de l'URI de la requete Http :
# GET blabla/bla/foo/CBI Http/1.1
#
########################################################################
server {
listen 6066;
server_name Ocpp-WS-BackEnd ;
location / {
set $proxy "unknown0";
proxy_read_timeout 100000000;
access_by_lua_block {
local cbi="no_cbi_in_ws_path"
local path=ngx.unescape_uri(ngx.var.request_uri)
for token in string.gmatch(path, "[^/?=]+") do cbi=token end
ngx.var.proxy = cbi
}
proxy_pass http://$proxy:6066/ocpp/$proxy;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}