feat(deploy): add edge proxy HTTPS and AmneziaWG tunnel templates
This commit is contained in:
1 parent
bdc5855001
commit
b8c3c83ed8
21 files changed
+954
-3
No files matched your search
@@ -0,0 +1,27 @@
|
||||
# Catch-all for requests whose Host is not a served name, on the one address
|
||||
# this edge uses. It keeps unknown names away from the application and
|
||||
# stops the TLS handshake without presenting a certificate.
|
||||
#
|
||||
# Rendered from deploy/edge/nginx/00-default.conf.template. Do not edit the
|
||||
# installed copy; change the template and render again.
|
||||
|
||||
# Access log without the query string: $uri never contains it, so values
|
||||
# such as email addresses or tokens in a query are not written to the log.
|
||||
log_format lincodex '$remote_addr [$time_local] "$request_method $uri" '
|
||||
'$status $body_bytes_sent rt=$request_time '
|
||||
'urt=$upstream_response_time id=$request_id';
|
||||
|
||||
server {
|
||||
listen {{EDGE_LISTEN_IP}}:80 default_server;
|
||||
server_name _;
|
||||
server_tokens off;
|
||||
# 444 closes the connection without a response.
|
||||
return 444;
|
||||
}
|
||||
|
||||
server {
|
||||
listen {{EDGE_LISTEN_IP}}:443 ssl default_server;
|
||||
server_name _;
|
||||
server_tokens off;
|
||||
ssl_reject_handshake on;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
# Port 80 for {{EDGE_DOMAIN}}: ACME http-01 challenges and the redirect to
|
||||
# HTTPS. This is the only file needed to obtain the first certificate.
|
||||
#
|
||||
# Rendered from deploy/edge/nginx/lincodex-http.conf.template.
|
||||
|
||||
server {
|
||||
listen {{EDGE_LISTEN_IP}}:80;
|
||||
server_name {{EDGE_DOMAIN}};
|
||||
server_tokens off;
|
||||
access_log /var/log/nginx/lincodex.access.log lincodex;
|
||||
|
||||
# Certbot writes challenge files here (webroot method). Nothing else is
|
||||
# served from this directory.
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root {{EDGE_ACME_WEBROOT}};
|
||||
default_type text/plain;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# The target uses the configured name, not $host, so a forged Host header
|
||||
# cannot turn the redirect into an open redirect.
|
||||
location / {
|
||||
return 301 https://{{EDGE_DOMAIN}}$request_uri;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
# Port 443 for {{EDGE_DOMAIN}}: TLS termination and a reverse proxy to the
|
||||
# frontend container of the app host, reached through the AmneziaWG tunnel.
|
||||
# The frontend container serves the SPA (including the index.html fallback
|
||||
# for deep links) and proxies /api to the Go backend, so this proxy forwards
|
||||
# every path unchanged and both live on one origin.
|
||||
#
|
||||
# Rendered from deploy/edge/nginx/lincodex-https.conf.template. Needs the
|
||||
# certificate from certbot; install it only after the first issuance.
|
||||
|
||||
upstream lincodex_app {
|
||||
server {{EDGE_UPSTREAM}};
|
||||
# Reused connections to the app host; the tunnel round trip is the
|
||||
# expensive part of a request.
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
server {
|
||||
listen {{EDGE_LISTEN_IP}}:443 ssl;
|
||||
# No HTTP/3: QUIC would need UDP 443, which another service on this host
|
||||
# already owns.
|
||||
http2 on;
|
||||
server_name {{EDGE_DOMAIN}};
|
||||
server_tokens off;
|
||||
access_log /var/log/nginx/lincodex.access.log lincodex;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/{{EDGE_CERT_NAME}}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{EDGE_CERT_NAME}}/privkey.pem;
|
||||
|
||||
# Mozilla "intermediate" profile: TLS 1.2 and 1.3, AEAD suites with
|
||||
# forward secrecy. The client picks the suite (prefer_server_ciphers off).
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:lincodex_tls:10m;
|
||||
# Tickets would keep one long-lived key that undoes forward secrecy.
|
||||
ssl_session_tickets off;
|
||||
# OCSP stapling is deliberately absent: Let's Encrypt certificates no
|
||||
# longer carry an OCSP responder URL, so there is nothing to staple.
|
||||
|
||||
# HSTS without preload. The header is set at server level only; a nested
|
||||
# add_header in a location would drop it.
|
||||
add_header Strict-Transport-Security "max-age={{EDGE_HSTS_MAX_AGE}}; includeSubDomains" always;
|
||||
|
||||
# Largest accepted request body. The resume upload limit is 5 MB; the
|
||||
# frontend container allows 10 MB, and this value must not be lower.
|
||||
client_max_body_size {{EDGE_MAX_BODY}};
|
||||
client_header_timeout 15s;
|
||||
client_body_timeout 60s;
|
||||
send_timeout 60s;
|
||||
|
||||
# Compression for the static shell only. gzip over responses that mix
|
||||
# secrets with attacker-influenced content enables BREACH, so JSON is not
|
||||
# in gzip_types and the API location turns compression off outright.
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 5;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/css text/javascript application/javascript image/svg+xml;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
# Clear Connection so the upstream keepalive pool is used.
|
||||
proxy_set_header Connection "";
|
||||
# Host is preserved: the backend and the frontend container see the public
|
||||
# name, which is what origin and link checks compare against.
|
||||
proxy_set_header Host $host;
|
||||
# The edge is the first trusted hop, so it replaces client-supplied
|
||||
# forwarding headers instead of appending to them.
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_redirect off;
|
||||
proxy_connect_timeout 5s;
|
||||
proxy_send_timeout 60s;
|
||||
# The frontend container gives the backend 30 s; leave room for it.
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
location ^~ /api/ {
|
||||
gzip off;
|
||||
proxy_pass http://lincodex_app;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://lincodex_app;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user