Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/ops/nginx/progmaweb.conf
blob: f752b805a5ee3f49f3b5c1ebd8438b88a285e3e2 (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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
# SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
# SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1

# Only a WebSocket upgrade reaches the applications. Forwarding any Upgrade
# header with "Connection: upgrade" on every request would let a client ask an
# upstream for another protocol (h2c) behind Nginx.
map $http_upgrade $progmaweb_upgrade {
    default   "";
    ~*^websocket$ websocket;
}

map $progmaweb_upgrade $progmaweb_connection {
    default   "";
    websocket upgrade;
}

server {
    listen 80;
    listen [::]:80;
    server_name progmasoft.com www.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://progmasoft.com$request_uri;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name account.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://account.progmasoft.com$request_uri;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name viget.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://viget.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name www.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

    return 308 https://progmasoft.com$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 1m;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_set_header Upgrade $progmaweb_upgrade;
        proxy_set_header Connection $progmaweb_connection;
        proxy_read_timeout 60s;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name account.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 1m;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    # Account, authentication, recovery, dashboard, and API responses are not
    # public search documents. The header also covers non-HTML responses.
    add_header X-Robots-Tag "noindex, nofollow, noarchive" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_set_header Upgrade $progmaweb_upgrade;
        proxy_set_header Connection $progmaweb_connection;
        proxy_read_timeout 60s;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name viget.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 1m;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    location = /login {
        return 308 https://account.progmasoft.com/login$is_args$args;
    }

    location = /register {
        return 308 https://account.progmasoft.com/register$is_args$args;
    }

    location = /recover {
        return 308 https://account.progmasoft.com/recover$is_args$args;
    }

    location = /api/v1/status {
        proxy_http_version 1.1;
        proxy_pass http://127.0.0.1:5080;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;
    }

    # The index of a Tazel plugin, which Tazel reads to choose a version and
    # check the JAR it downloads: from the API, under its own path.
    location ~ "^/dslplugins/tazel/([A-Za-z_][A-Za-z0-9_]*)/([A-Za-z_][A-Za-z0-9_]*)/index\.json$" {
        proxy_http_version 1.1;
        proxy_pass http://127.0.0.1:5085/api/v1/viget/dslplugins/tazel/$1/$2/index.json;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;
        add_header Cache-Control "no-cache" always;
        add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
        add_header X-Content-Type-Options "nosniff" always;
    }

    # The JARs of Tazel plugins, from the files of ViGet. A version is never
    # replaced, so a JAR is cached for good.
    location ~ "^/dslplugins/tazel/[A-Za-z_][A-Za-z0-9_]*/[A-Za-z_][A-Za-z0-9_]*/[0-9A-Za-z.+-]+/[A-Za-z_][A-Za-z0-9_]*-[0-9A-Za-z.+-]+\.jar$" {
        root /srv/viget/files;
        default_type application/java-archive;
        types { }
        add_header Cache-Control "public, max-age=31536000, immutable" always;
        add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
        add_header X-Content-Type-Options "nosniff" always;
    }

    location ^~ /api/ {
        return 404;
    }

    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_set_header Upgrade $progmaweb_upgrade;
        proxy_set_header Connection $progmaweb_connection;
        proxy_read_timeout 60s;
    }
}

# Progmasoft OAuth: the OAuth 2.1 and OpenID Connect provider of Progmasoft
# accounts. credentials.progmasoft.com is the issuer: the discovery documents,
# the key set and the endpoints clients call directly go to the account API;
# its home page is a page of the Next.js site.
server {
    listen 80;
    listen [::]:80;
    server_name credentials.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://credentials.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name credentials.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 64k;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header X-Robots-Tag "noindex, nofollow, noarchive" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    # The protocol endpoints, the discovery documents and the JSON endpoints of
    # the pages belong to the account API; it answers only OAuth paths here.
    location ~ ^/(connect|\.well-known|api)/ {
        proxy_pass http://127.0.0.1:5085;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_read_timeout 30s;
    }

    # The home page of the issuer is a page of the Progmasoft site.
    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_set_header Upgrade $progmaweb_upgrade;
        proxy_set_header Connection $progmaweb_connection;
        proxy_read_timeout 60s;
    }
}

# authorize.progmasoft.com: the pages people see in Progmasoft OAuth. The
# authorization and end session endpoints and the JSON paths of the pages go to
# the account API; sign-in, the consent screen and the allowed applications are
# pages of the Next.js site.
server {
    listen 80;
    listen [::]:80;
    server_name authorize.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://authorize.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name authorize.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 64k;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header X-Robots-Tag "noindex, nofollow, noarchive" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    # The authorization and end session endpoints and the JSON endpoints of the
    # pages belong to the account API; it answers only those here.
    location ~ ^/(connect|api)/ {
        proxy_pass http://127.0.0.1:5085;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_read_timeout 30s;
    }

    # Sign-in, the consent screen and the allowed applications are pages of the
    # Progmasoft site.
    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_set_header Upgrade $progmaweb_upgrade;
        proxy_set_header Connection $progmaweb_connection;
        proxy_read_timeout 60s;
    }
}

# The Progmasoft Console: developers make and manage the tokens of their
# applications here, signed in with their Progmasoft account session. The JSON
# paths go to the account API; the pages are pages of the Next.js site.
server {
    listen 80;
    listen [::]:80;
    server_name console.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://console.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name console.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 64k;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header X-Robots-Tag "noindex, nofollow, noarchive" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    location ^~ /api/ {
        proxy_pass http://127.0.0.1:5085;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_read_timeout 30s;
    }

    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_set_header Upgrade $progmaweb_upgrade;
        proxy_set_header Connection $progmaweb_connection;
        proxy_read_timeout 60s;
    }
}

# The product catalog (product.progmasoft.com) and the product site Progmaweb
# serves itself (catch3.progmasoft.com): pages of the Next.js site only.
server {
    listen 80;
    listen [::]:80;
    server_name product.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://product.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name product.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 1m;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_read_timeout 60s;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name catch3.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://catch3.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name catch3.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    client_max_body_size 1m;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "DENY" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;

    location / {
        proxy_pass http://127.0.0.1:3010;
        proxy_http_version 1.1;
        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_set_header X-Forwarded-Host $host;
        proxy_read_timeout 60s;
    }
}

# The Maven repository of Progmasoft: /tazel holds com.progmasoft.tazel:tazel-api,
# which plugins of Tazel compile against. Static files only, copied from the
# Gradle staging repository of a release; see ops/README.md.
server {
    listen 80;
    listen [::]:80;
    server_name maven.progmasoft.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/lib/letsencrypt;
        default_type text/plain;
    }

    location / {
        return 308 https://maven.progmasoft.com$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name maven.progmasoft.com;

    ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;

    root /srv/maven;
    autoindex on;

    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Robots-Tag "noindex" always;

    location = / {
        return 302 https://maven.progmasoft.com/tazel/;
    }

    location ^~ /tazel/ {
        try_files $uri $uri/ =404;
    }

    location / {
        return 404;
    }
}