summaryrefslogtreecommitdiff
path: root/etc/nginx/sites-enabled/test.site
blob: 306604290bad5996405cffa9dbef7b0ab5995eed (plain)
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
server {
  listen 80;
  listen [::]:80;
  server_name test.taler.net
              bank.test.taler.net
              shop.test.taler.net
              donations.test.taler.net
              survey.test.taler.net
              auditor.test.taler.net
              exchange.test.taler.net;

  # 301-based ridirects allows the user agent to *change* the
  # method used in the second request.  This breaks all the API
  # using POST, as some user agents do the second request using
  # GET.  307 is meant to tell the user agent to not change the
  # method in the second request.
  if ($request_method = POST) { return 307 https://$host$request_uri; }
  return 301 https://$host$request_uri;
}

server {
  server_name test.taler.net www.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  rewrite /javascript /javascript.html break;
  include conf.d/test.redirects;
  include conf.d/talerssl;
  location @green {
    add_header X-Taler-Deployment-Color green;
    root /home/test-green/landing/demo;
  }
  location @blue {
    add_header X-Taler-Deployment-Color blue;
    root /home/test-blue/landing/demo;
  }
  location / {
    # Redirection technique explainted at
    # https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    error_page 418 = @blue;
    error_page 419 = @green;
    rewrite ^/$ /en/ redirect;
    rewrite ^/(..)/$ /$1/index.html break;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    root /home/test/landing/demo;
  }
  include conf.d/favicon_robots;
}


server {
  server_name auditor.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  root /dev/null;
  include conf.d/test.redirects;
  include conf.d/talerssl;
  location @green {
    add_header X-Taler-Deployment-Color green;
    uwsgi_pass unix:/home/test-green/sockets/auditor.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
  location @blue {
    add_header X-Taler-Deployment-Color blue;
    uwsgi_pass unix:/home/test-blue/sockets/auditor.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
  location / {
    # Redirection technique explainted at
    # https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    error_page 418 = @blue;
    error_page 419 = @green;
    rewrite ^/$ /en/ redirect;
    rewrite ^/(..)/$ /$1/index.html break;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    uwsgi_pass unix:/home/test/sockets/auditor.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
  include conf.d/favicon_robots;
}


server {
  server_name exchange.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  root /dev/null;
  include conf.d/talerssl;
  location @blue-admin {
    add_header X-Taler-Deployment-Color blue;
    proxy_pass http://unix:/home/test-blue/sockets/exchange-admin.http;
    proxy_redirect off;
    proxy_set_header Host $host;
  }
  location @green-admin {
    add_header X-Taler-Deployment-Color green;
    proxy_pass http://unix:/home/test-green/sockets/exchange-admin.http;
    proxy_redirect off;
    proxy_set_header Host $host;
  }

  location @blue {
    add_header X-Taler-Deployment-Color blue;
    proxy_pass http://unix:/home/test-blue/sockets/exchange.http;
    proxy_redirect off;
    proxy_set_header Host $host;
  }

  location @green {
    add_header X-Taler-Deployment-Color green;
    proxy_pass http://unix:/home/test-green/sockets/exchange.http;
    proxy_redirect off;
    proxy_set_header Host $host;
  }

  location /admin {
    error_page 418 = @blue-admin;
    error_page 419 = @green-admin;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    proxy_pass http://unix:/home/test/sockets/exchange-admin.http;
    proxy_redirect off;
    proxy_set_header Host $host;
  }

  location / {
    error_page 418 = @blue;
    error_page 419 = @green;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    proxy_pass http://unix:/home/test/sockets/exchange.http:/;
    proxy_redirect off;
    proxy_set_header Host $host;
  }
}


server {
  server_name shop.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  root /dev/null;
  include conf.d/test.redirects;
  include conf.d/talerssl;

  location @blue {
    add_header X-Taler-Deployment-Color blue;
    uwsgi_pass unix:/home/test-blue/sockets/shop.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
  location @green {
    add_header X-Taler-Deployment-Color green;
    uwsgi_pass unix:/home/test-green/sockets/shop.uwsgi;
    include /etc/nginx/uwsgi_params;
  }

  location / {
    # Redirection technique explainted at
    # https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    error_page 418 = @blue;
    error_page 419 = @green;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    uwsgi_pass unix:/home/test/sockets/shop.uwsgi;
    include /etc/nginx/uwsgi_params;
  }

  include conf.d/favicon_robots;
}


server {
  server_name backend.test.taler.net;
  listen 443 ssl;
  listen 80;
  listen [::]:443 ssl;
  listen [::]:80;
  include conf.d/talerssl;

  location @blue {
    add_header X-Taler-Deployment-Color blue;
    proxy_pass http://unix:/home/test-blue/sockets/merchant.http;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host "backend.test.taler.net";
    proxy_set_header X-Forwarded-Proto "https";
  }
  location @green {
    add_header X-Taler-Deployment-Color green;
    proxy_pass http://unix:/home/test-green/sockets/merchant.http;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host "backend.test.taler.net";
    proxy_set_header X-Forwarded-Proto "https";
  }

  location / {
    # Redirection technique explainted at
    # https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    error_page 418 = @blue;
    error_page 419 = @green;
    recursive_error_pages on;

    # This is very ugly, but necessary since NGINX
    # can't do multiple conditions or nexted ifs

    if ($request_filename !~ "^/public/?.*$") {
      # restricted!
      set $authresult "r";
    }

    if ($http_authorization = "ApiKey sandbox") {
      # auth successful
      set $authresult "${authresult}y";
    }
    if ($authresult = "r") {
      # restricted but not authorized
      return 401;
    }
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    proxy_set_header X-Forwarded-Host "backend.test.taler.net";
    proxy_set_header X-Forwarded-Proto "https";
    proxy_pass http://unix:/home/test/sockets/merchant.http:/;
    proxy_redirect off;
    proxy_set_header Host $host;
  }
}


server {
  server_name survey.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  include conf.d/test.redirects;
  include conf.d/talerssl;

  location / {
    uwsgi_pass unix:/home/test/sockets/survey.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
}

server {
  server_name donations.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  include conf.d/test.redirects;
  include conf.d/talerssl;

  location @blue {
    add_header X-Taler-Deployment-Color blue;
    uwsgi_pass unix:/home/test-blue/sockets/donations.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
  location @green {
    add_header X-Taler-Deployment-Color green;
    uwsgi_pass unix:/home/test-green/sockets/donations.uwsgi;
    include /etc/nginx/uwsgi_params;
  }

  location / {
    # Redirection technique explainted at
    # https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    error_page 418 = @blue;
    error_page 419 = @green;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    uwsgi_pass unix:/home/test/sockets/donations.uwsgi;
    include /etc/nginx/uwsgi_params;
  }

  include conf.d/favicon_robots;
}


server {
  server_name bank.test.taler.net;
  listen 443 ssl;
  listen [::]:443 ssl;
  include conf.d/test.redirects;
  include conf.d/talerssl;

  location @blue {
    add_header X-Taler-Deployment-Color blue;
    uwsgi_pass unix:/home/test-blue/sockets/bank.uwsgi;
    include /etc/nginx/uwsgi_params;
  }
  location @green {
    add_header X-Taler-Deployment-Color green;
    uwsgi_pass unix:/home/test-green/sockets/bank.uwsgi;
    include /etc/nginx/uwsgi_params;
  }

  location / {
    # Redirection technique explainted at
    # https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    error_page 418 = @blue;
    error_page 419 = @green;
    recursive_error_pages on;
    if ($http_x_taler_deployment_color ~ "blue") { return 418; }
    if ($http_x_taler_deployment_color ~ "green") { return 419; }
    uwsgi_pass unix:/home/test/sockets/bank.uwsgi;
    include /etc/nginx/uwsgi_params;
  }

  include conf.d/favicon_robots;
}