Repository navigation
Expand file tree
/
Copy path10-pyble-dev-https.conf
More file actions
160 lines (133 loc) · 4.86 KB
/
Copy path10-pyble-dev-https.conf
File metadata and controls
160 lines (133 loc) · 4.86 KB
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
# SPDX-License-Identifier: MIT
# Part of PyBLE (https://pyble.dev) — see /LICENSE.
#
# Installed as /etc/nginx/sites-available/10-pyble-dev-https.conf after the
# pyble.dev certificate has been issued.
map $status $pyble_firmware_cache_control {
~^(?:2[0-9][0-9]|304)$ "public, max-age=31536000, immutable";
default "no-store";
}
# $request_uri retains the original public path across the internal 404-page
# redirect. Keep missing immutable firmware paths and the retired unversioned
# social cards out of caches while retaining the normal no-cache/no-transform
# policy for the shared website 404 page.
map $request_uri $pyble_not_found_cache_control {
"/social/pyble-beta-og-1200x630.png" "no-store";
"/social/pyble-beta-og-1200x630.svg" "no-store";
~^/social/pyble-beta-og-1200x630\.png\? "no-store";
~^/social/pyble-beta-og-1200x630\.svg\? "no-store";
~^/firmware/ "no-store";
default "no-cache, no-transform";
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name pyble.dev;
ssl_certificate /etc/letsencrypt/live/pyble.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/pyble.dev/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
root /srv/pyble/current;
index index.html;
charset utf-8;
server_tokens off;
include /etc/nginx/snippets/pyble-security-headers.conf;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types application/javascript application/json application/manifest+json image/svg+xml text/css text/plain;
location = / {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files /index.html =404;
}
location = /privacy {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files /privacy.html =404;
}
location = /support {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files /support.html =404;
}
location = /flash {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files /flash.html =404;
}
location = /privacy/ {
return 308 https://pyble.dev/privacy$is_args$args;
}
location = /support/ {
return 308 https://pyble.dev/support$is_args$args;
}
location = /flash/ {
return 308 https://pyble.dev/flash$is_args$args;
}
location ^~ /_next/static/ {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "public, max-age=31536000, immutable" always;
try_files $uri =404;
}
location ^~ /firmware/ {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control $pyble_firmware_cache_control always;
alias /srv/pyble/firmware/;
types {
application/json json;
application/octet-stream bin;
text/markdown md;
text/plain txt;
}
default_type application/octet-stream;
}
location = /manifest.webmanifest {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
default_type application/manifest+json;
try_files $uri =404;
}
location = /robots.txt {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files $uri =404;
}
location = /sitemap.xml {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files $uri =404;
}
location ~ \.txt$ {
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control "no-cache, no-transform" always;
try_files $uri =404;
}
location ~ /\. {
deny all;
}
location / {
try_files $uri =404;
}
error_page 404 /404.html;
location = /404.html {
internal;
include /etc/nginx/snippets/pyble-security-headers.conf;
add_header Cache-Control $pyble_not_found_cache_control always;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.pyble.dev;
ssl_certificate /etc/letsencrypt/live/pyble.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/pyble.dev/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
include /etc/nginx/snippets/pyble-security-headers.conf;
return 308 https://pyble.dev$request_uri;
}