-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
225 lines (186 loc) · 8.8 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
events {}
daemon off;
http {
server {
listen $WP_SERVER_PORT;
$WP_SERVER_TLS_DIRECTIVES
$WP_SERVER_FILE_INCLUDES
keepalive_timeout 70;
gzip on;
auth_basic "$WP_SERVER_BASIC_AUTH";
auth_basic_user_file /etc/nginx/.htpasswd;
location = / {
return 200 'Welcome to Wenrix Proxy\n';
}
resolver $WP_SERVER_RESOLVER;
location ~ ^/channel/britishairways/(.*) {
proxy_pass $WP_CHANNELS_BA_PROXY_PASS/$1;
proxy_set_header Host $WP_CHANNELS_BA_HOST;
proxy_ssl_server_name on;
proxy_connect_timeout 30;
proxy_send_timeout 120;
proxy_read_timeout 120;
send_timeout 120;
# Drop HTTP headers that are not needed (Wenrix headers)
proxy_set_header x-wenrix-operation "";
proxy_set_header x-wenrix-trace-id "";
proxy_set_header authorization "";
proxy_set_header x-real-ip "";
proxy_set_header x-forwarded-for "";
# Add the Authorization header
proxy_set_header Client-Key "$WP_CHANNELS_BA_API_KEY";
}
location /channel/travelfusion {
proxy_pass $WP_CHANNELS_TRAVELFUSION_PROXY_PASS;
proxy_set_header Host $WP_CHANNELS_TRAVELFUSION_HOST;
proxy_set_header Content-Type text/xml;
proxy_ssl_server_name on;
proxy_connect_timeout 30;
proxy_send_timeout 120;
proxy_read_timeout 120;
send_timeout 120;
# Drop HTTP headers that are not needed (Wenrix headers)
proxy_set_header x-wenrix-operation "";
proxy_set_header x-wenrix-trace-id "";
proxy_set_header x-wenrix-iata-number "";
proxy_set_header x-wenrix-supplier "";
proxy_set_header authorization "";
proxy_set_header x-real-ip "";
proxy_set_header x-forwarded-for "";
lua_need_request_body on;
access_by_lua_block
{
require "travelfusion"
local login_id = "$WP_CHANNELS_TRAVELFUSION_LOGIN_ID"
local xml_login_id = "$WP_CHANNELS_TRAVELFUSION_XML_LOGIN_ID"
ngx.req.read_body()
local body = ngx.req.get_body_data()
local config = load_config()
local iata_number = ngx.req.get_headers()["x-wenrix-iata-number"]
local supplier = ngx.req.get_headers()["x-wenrix-supplier"]
local supplier_list = ""
if iata_number and supplier and config[iata_number] and config[iata_number][supplier] then
supplier_list = build_supplier_labels(supplier, config[iata_number][supplier])
end
if body then
body = ngx.re.gsub(body, "<LoginId>PLACEHOLDER</LoginId>", "<LoginId>" .. login_id .. "</LoginId>")
body = ngx.re.gsub(body, "<XmlLoginId>PLACEHOLDER</XmlLoginId>", "<XmlLoginId>" .. xml_login_id .. "</XmlLoginId>")
body = ngx.re.gsub(body, "<CustomSupplierParameterList>PLACEHOLDER</CustomSupplierParameterList>", "<CustomSupplierParameterList>" .. supplier_list .. "</CustomSupplierParameterList>")
end
ngx.req.set_body_data(body)
}
}
location ~ ^/channel/farelogix-aa/(.*) {
proxy_pass $WP_CHANNELS_FARELOGIX_AA_PROXY_PASS/$1;
proxy_set_header Host $WP_CHANNELS_FARELOGIX_AA_HOST;
proxy_ssl_server_name on;
proxy_connect_timeout 30;
proxy_send_timeout 120;
proxy_read_timeout 120;
send_timeout 120;
# Drop HTTP headers that are not needed (Wenrix headers)
proxy_set_header x-wenrix-operation "";
proxy_set_header x-wenrix-trace-id "";
proxy_set_header authorization "";
proxy_set_header x-real-ip "";
proxy_set_header x-forwarded-for "";
# Add API key header
proxy_set_header Ocp-Apim-Subscription-Key "$WP_CHANNELS_FARELOGIX_AA_API_KEY";
lua_need_request_body on;
access_by_lua_block {
local agent = "$WP_CHANNELS_FARELOGIX_AA_AGENT"
local username = "$WP_CHANNELS_FARELOGIX_AA_USERNAME"
local password = "$WP_CHANNELS_FARELOGIX_AA_PASSWORD"
local agent_user = "$WP_CHANNELS_FARELOGIX_AA_AGENT_USER"
local agent_password = "$WP_CHANNELS_FARELOGIX_AA_AGENT_PASSWORD"
ngx.req.read_body()
local body = ngx.req.get_body_data()
if body then
body = ngx.re.gsub(body, "#FLX_USERNAME#", username)
body = ngx.re.gsub(body, "#FLX_PASSWORD#", password)
body = ngx.re.gsub(body, "#FLX_AGENT#", agent)
body = ngx.re.gsub(body, "#FLX_AGENT_USER#", agent_user)
body = ngx.re.gsub(body, "#FLX_AGENT_PASSWORD#", agent_password)
end
ngx.req.set_body_data(body)
}
}
location ~ ^/channel/farelogix-lh/(.*) {
proxy_pass $WP_CHANNELS_FARELOGIX_LH_PROXY_PASS/$1;
proxy_set_header Host $WP_CHANNELS_FARELOGIX_LH_HOST;
proxy_ssl_server_name on;
proxy_connect_timeout 30;
proxy_send_timeout 120;
proxy_read_timeout 120;
send_timeout 120;
# Drop HTTP headers that are not needed (Wenrix headers)
proxy_set_header x-wenrix-operation "";
proxy_set_header x-wenrix-trace-id "";
proxy_set_header authorization "";
proxy_set_header x-real-ip "";
proxy_set_header x-forwarded-for "";
# Add API key header
proxy_set_header Ocp-Apim-Subscription-Key "$WP_CHANNELS_FARELOGIX_LH_API_KEY";
lua_need_request_body on;
access_by_lua_block {
local agent = "$WP_CHANNELS_FARELOGIX_LH_AGENT"
local username = "$WP_CHANNELS_FARELOGIX_LH_USERNAME"
local password = "$WP_CHANNELS_FARELOGIX_LH_PASSWORD"
local agent_user = "$WP_CHANNELS_FARELOGIX_LH_AGENT_USER"
local agent_password = "$WP_CHANNELS_FARELOGIX_LH_AGENT_PASSWORD"
ngx.req.read_body()
local body = ngx.req.get_body_data()
if body then
body = ngx.re.gsub(body, "#FLX_USERNAME#", username)
body = ngx.re.gsub(body, "#FLX_PASSWORD#", password)
body = ngx.re.gsub(body, "#FLX_AGENT#", agent)
body = ngx.re.gsub(body, "#FLX_AGENT_USER#", agent_user)
body = ngx.re.gsub(body, "#FLX_AGENT_PASSWORD#", agent_password)
end
ngx.req.set_body_data(body)
}
}
location ~ ^/channel/farelogix-ua/(.*) {
proxy_pass $WP_CHANNELS_FARELOGIX_UA_PROXY_PASS/$1;
proxy_set_header Host $WP_CHANNELS_FARELOGIX_UA_HOST;
proxy_ssl_server_name on;
proxy_connect_timeout 30;
proxy_send_timeout 120;
proxy_read_timeout 120;
send_timeout 120;
# Drop HTTP headers that are not needed (Wenrix headers)
proxy_set_header x-wenrix-operation "";
proxy_set_header x-wenrix-trace-id "";
proxy_set_header authorization "";
proxy_set_header x-real-ip "";
proxy_set_header x-forwarded-for "";
# Add API key header
proxy_set_header Ocp-Apim-Subscription-Key "$WP_CHANNELS_FARELOGIX_UA_API_KEY";
lua_need_request_body on;
access_by_lua_block {
local agent = "$WP_CHANNELS_FARELOGIX_UA_AGENT"
local username = "$WP_CHANNELS_FARELOGIX_UA_USERNAME"
local password = "$WP_CHANNELS_FARELOGIX_UA_PASSWORD"
local agent_user = "$WP_CHANNELS_FARELOGIX_UA_AGENT_USER"
local agent_password = "$WP_CHANNELS_FARELOGIX_UA_AGENT_PASSWORD"
ngx.req.read_body()
local body = ngx.req.get_body_data()
if body then
body = ngx.re.gsub(body, "#FLX_USERNAME#", username)
body = ngx.re.gsub(body, "#FLX_PASSWORD#", password)
body = ngx.re.gsub(body, "#FLX_AGENT#", agent)
body = ngx.re.gsub(body, "#FLX_AGENT_USER#", agent_user)
body = ngx.re.gsub(body, "#FLX_AGENT_PASSWORD#", agent_password)
end
ngx.req.set_body_data(body)
}
}
location /metrics {
stub_status;
}
error_page 404 /404.html;
location = /404.html {
internal;
}
}
}