forked from ssbc/go-ssb-room
-
Notifications
You must be signed in to change notification settings - Fork 2
/
example-nginx.conf
75 lines (61 loc) · 2.83 KB
/
example-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
# SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021
#
# SPDX-License-Identifier: Unlicense
server {
server_name planetary.name;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/planetary.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/planetary.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://localhost:8899;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_set_header X-Forwarded-Proto $scheme;
# for websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
# requires a $connection_upgrade definition in /etc/nginx/nginx.conf
# see https://futurestud.io/tutorials/nginx-how-to-fix-unknown-connection_upgrade-variable
proxy_set_header Connection $connection_upgrade;
}
# TODO: https://blog.tarq.io/nginx-catch-all-error-pages/
}
# this server uses the (same) wildcard cert as the one above but uses a regular expression on the hostname
# which extracts the first subdomain which holds the alias and forwards that to the prox_pass server
server {
server_name "~^(?<alias>\w+)\.hermies\.club$";
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/planetary.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/planetary.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location = / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_set_header X-Forwarded-Proto $scheme;
# "rewrite" requests with subdomains to the non-wildcard url for alias resolving
# $is_args$args pass on ?encoding=json if present
proxy_pass http://localhost:8899/alias/$alias$is_args$args;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8899;
}
# TODO: https://blog.tarq.io/nginx-catch-all-error-pages/
}
server {
if ($host ~ planetary.name$ ) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name planetary.name;
return 404; # managed by Certbot
}