2022-06-10 19:40:32 -04:00
|
|
|
# nginx 1.22.x
|
2021-05-24 13:52:50 -04:00
|
|
|
|
|
|
|
load_module modules/ngx_http_brotli_static_module.so;
|
|
|
|
|
2023-02-11 04:07:55 -05:00
|
|
|
error_log syslog:server=unix:/dev/log,nohostname;
|
2023-03-07 11:00:08 -05:00
|
|
|
# leave stderr open but minimize duplicate logging to it
|
|
|
|
error_log stderr emerg;
|
2023-02-11 04:07:55 -05:00
|
|
|
|
2021-05-24 13:52:50 -04:00
|
|
|
worker_processes auto;
|
|
|
|
worker_rlimit_nofile 16384;
|
|
|
|
|
|
|
|
events {
|
|
|
|
worker_connections 4096;
|
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
2023-02-19 11:51:37 -05:00
|
|
|
root /var/empty;
|
|
|
|
|
2021-05-24 13:52:50 -04:00
|
|
|
include mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
|
|
|
charset utf-8;
|
2021-12-10 05:55:59 -05:00
|
|
|
charset_types text/css text/plain text/xml application/atom+xml application/javascript;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
2022-05-03 19:10:31 -04:00
|
|
|
sendfile on;
|
2021-05-24 13:52:50 -04:00
|
|
|
sendfile_max_chunk 512k;
|
|
|
|
tcp_nopush on;
|
2022-09-24 11:53:02 -04:00
|
|
|
keepalive_requests 256;
|
2021-05-24 13:52:50 -04:00
|
|
|
keepalive_timeout 3m;
|
|
|
|
server_tokens off;
|
|
|
|
msie_padding off;
|
|
|
|
|
|
|
|
client_max_body_size 1k;
|
|
|
|
client_body_buffer_size 1k;
|
|
|
|
client_header_buffer_size 1k;
|
2022-09-24 11:11:01 -04:00
|
|
|
large_client_header_buffers 2 1k;
|
2022-09-26 13:14:40 -04:00
|
|
|
http2_chunk_size 4k;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
2023-02-09 18:42:51 -05:00
|
|
|
client_body_timeout 15s;
|
|
|
|
client_header_timeout 15s;
|
2021-05-24 13:52:50 -04:00
|
|
|
send_timeout 30s;
|
|
|
|
|
2023-02-14 10:33:25 -05:00
|
|
|
max_ranges 1;
|
|
|
|
|
2022-05-02 04:10:42 -04:00
|
|
|
resolver [::1];
|
2022-10-12 16:30:25 -04:00
|
|
|
resolver_timeout 15s;
|
2022-05-02 04:10:42 -04:00
|
|
|
|
2022-09-24 11:22:11 -04:00
|
|
|
http2_max_concurrent_streams 16;
|
2021-05-24 13:52:50 -04:00
|
|
|
limit_conn_status 429;
|
2023-02-11 04:26:52 -05:00
|
|
|
limit_conn_zone $binary_remote_addr zone=http-limit:10m;
|
|
|
|
limit_conn http-limit 128;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256;
|
|
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
ssl_conf_command Options PrioritizeChaCha;
|
|
|
|
|
|
|
|
ssl_certificate /etc/letsencrypt/live/matrix.grapheneos.org/fullchain.pem;
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/matrix.grapheneos.org/privkey.pem;
|
|
|
|
|
|
|
|
# maintained by nginx-rotate-session-ticket-keys in ramfs
|
|
|
|
ssl_session_ticket_key session-ticket-keys/4.key;
|
|
|
|
ssl_session_ticket_key session-ticket-keys/3.key;
|
|
|
|
ssl_session_ticket_key session-ticket-keys/2.key;
|
|
|
|
ssl_session_ticket_key session-ticket-keys/1.key;
|
2022-04-30 22:47:18 -04:00
|
|
|
ssl_session_timeout 1d;
|
2021-05-24 13:52:50 -04:00
|
|
|
ssl_buffer_size 4k;
|
|
|
|
|
|
|
|
ssl_trusted_certificate /etc/letsencrypt/live/matrix.grapheneos.org/chain.pem;
|
|
|
|
ssl_stapling on;
|
|
|
|
ssl_stapling_verify on;
|
|
|
|
# maintained by certbot-ocsp-fetcher
|
|
|
|
ssl_stapling_file ocsp-cache/matrix.grapheneos.org.der;
|
|
|
|
|
2023-03-09 10:54:28 -05:00
|
|
|
log_format main '$connection-$connection_requests $remote_addr $remote_user $ssl_protocol $server_protocol '
|
2023-05-05 14:46:11 -04:00
|
|
|
'$host $request_method "$request_uri" $status $request_length $body_bytes_sent/$bytes_sent '
|
|
|
|
'$request_time $upstream_connect_time/$upstream_header_time/$upstream_response_time '
|
|
|
|
'$upstream_cache_status "$http_referer" "$http_user_agent"';
|
2022-09-27 10:27:36 -04:00
|
|
|
access_log syslog:server=unix:/dev/log,nohostname main;
|
2023-03-09 10:54:28 -05:00
|
|
|
log_subrequest on;
|
2021-05-24 13:52:50 -04:00
|
|
|
log_not_found off;
|
|
|
|
|
2021-07-04 03:34:49 -04:00
|
|
|
gzip_proxied any;
|
|
|
|
gzip_vary on;
|
|
|
|
|
2021-06-30 22:53:05 -04:00
|
|
|
if_modified_since before;
|
|
|
|
|
2021-06-30 22:59:59 -04:00
|
|
|
aio threads;
|
2021-11-28 19:02:37 -05:00
|
|
|
aio_write on;
|
2021-06-30 22:59:59 -04:00
|
|
|
|
2021-05-24 13:52:50 -04:00
|
|
|
upstream backend {
|
2021-12-03 22:33:54 -05:00
|
|
|
zone backend 32k;
|
2023-04-17 10:01:00 -04:00
|
|
|
server [::1]:8008 max_conns=4096 max_fails=0;
|
2021-05-24 13:52:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
2023-02-17 22:53:01 -05:00
|
|
|
listen 80 default_server backlog=4096;
|
|
|
|
listen [::]:80 default_server backlog=4096;
|
2023-02-26 10:50:11 -05:00
|
|
|
|
2023-02-17 22:53:01 -05:00
|
|
|
keepalive_timeout 0;
|
2023-02-26 10:50:11 -05:00
|
|
|
|
2023-02-18 12:38:10 -05:00
|
|
|
# https://trac.nginx.org/nginx/ticket/2012
|
|
|
|
location / {
|
|
|
|
return 404;
|
|
|
|
}
|
2023-02-17 22:53:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
2023-05-22 17:47:52 -04:00
|
|
|
server_name matrix.grapheneos.org element.grapheneos.org mta-sts.matrix.grapheneos.org;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
2023-02-27 02:37:42 -05:00
|
|
|
keepalive_timeout 0;
|
|
|
|
|
2023-02-09 09:53:16 -05:00
|
|
|
location /.well-known/acme-challenge/ {
|
|
|
|
root /srv/certbot;
|
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
}
|
2021-05-24 13:52:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
2023-02-17 22:53:01 -05:00
|
|
|
listen 443 default_server ssl backlog=4096;
|
|
|
|
listen [::]:443 default_server ssl backlog=4096;
|
|
|
|
ssl_reject_handshake on;
|
2023-03-06 11:01:29 -05:00
|
|
|
|
|
|
|
keepalive_timeout 0;
|
2023-03-07 10:36:12 -05:00
|
|
|
|
|
|
|
# https://trac.nginx.org/nginx/ticket/2012
|
2023-03-06 11:01:29 -05:00
|
|
|
location / {
|
|
|
|
return 404;
|
|
|
|
}
|
2023-02-17 22:53:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 443 ssl http2;
|
|
|
|
listen [::]:443 ssl http2;
|
2021-05-24 13:52:50 -04:00
|
|
|
server_name matrix.grapheneos.org;
|
|
|
|
|
|
|
|
include snippets/security-headers.conf;
|
2021-06-18 20:20:50 -04:00
|
|
|
add_header Cross-Origin-Resource-Policy "same-origin" always;
|
2021-07-22 00:12:22 -04:00
|
|
|
add_header Content-Security-Policy "font-src 'none'; manifest-src 'none'; object-src 'none'; script-src 'none'; style-src 'none'; frame-ancestors 'none'; block-all-mixed-content" always;
|
2021-06-18 05:34:44 -04:00
|
|
|
# obsolete and replaced with Content-Security-Policy frame-ancestors 'none'
|
2021-06-18 20:22:34 -04:00
|
|
|
add_header X-Frame-Options "DENY" always;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
|
|
|
location = / {
|
|
|
|
return 301 https://grapheneos.org/articles/grapheneos-servers#matrix.grapheneos.org;
|
|
|
|
}
|
|
|
|
|
2021-11-23 20:00:41 -05:00
|
|
|
location ~ ^(?:/_matrix|/_synapse/client) {
|
2021-07-02 11:12:56 -04:00
|
|
|
# remove security headers that are statically set to the strictest possible values below
|
|
|
|
proxy_hide_header Referrer-Policy;
|
2021-06-18 05:05:39 -04:00
|
|
|
proxy_hide_header X-Frame-Options;
|
2021-07-02 11:12:56 -04:00
|
|
|
|
2021-05-24 13:52:50 -04:00
|
|
|
include snippets/security-headers.conf;
|
2021-07-22 00:12:22 -04:00
|
|
|
add_header Content-Security-Policy "font-src 'none'; manifest-src 'none'; object-src 'none'; script-src 'none'; style-src 'none'; frame-ancestors 'none'; block-all-mixed-content" always;
|
2021-06-18 05:34:44 -04:00
|
|
|
# obsolete and replaced with Content-Security-Policy frame-ancestors 'none'
|
2021-06-18 20:22:34 -04:00
|
|
|
add_header X-Frame-Options "DENY" always;
|
2022-08-18 18:11:08 -04:00
|
|
|
add_header X-Robots-Tag "none" always;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
|
|
|
proxy_pass http://backend;
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_set_header Host $host;
|
2022-04-18 10:26:47 -04:00
|
|
|
proxy_connect_timeout 5s;
|
2022-06-27 23:58:50 -04:00
|
|
|
proxy_send_timeout 15s;
|
2021-06-07 14:46:25 -04:00
|
|
|
proxy_read_timeout 600s;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
2021-07-13 22:27:12 -04:00
|
|
|
client_max_body_size 100m;
|
2021-05-24 13:52:50 -04:00
|
|
|
client_body_buffer_size 16k;
|
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 404;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-18 05:21:42 -04:00
|
|
|
server {
|
|
|
|
listen 443 ssl http2;
|
|
|
|
listen [::]:443 ssl http2;
|
|
|
|
server_name element.grapheneos.org;
|
|
|
|
|
2021-07-06 13:53:00 -04:00
|
|
|
root /srv/element.grapheneos.org;
|
2021-06-18 05:21:42 -04:00
|
|
|
|
|
|
|
include snippets/security-headers.conf;
|
2021-07-13 22:27:38 -04:00
|
|
|
add_header Cross-Origin-Resource-Policy "cross-origin" always;
|
2021-07-22 00:12:22 -04:00
|
|
|
add_header Content-Security-Policy "font-src 'self'; manifest-src 'self'; object-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-ancestors 'self'; block-all-mixed-content" always;
|
2021-06-18 05:34:44 -04:00
|
|
|
# obsolete and replaced with Content-Security-Policy frame-ancestors 'self'
|
2021-06-18 20:22:34 -04:00
|
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
2022-08-18 18:11:08 -04:00
|
|
|
add_header X-Robots-Tag "none" always;
|
2021-07-06 13:53:00 -04:00
|
|
|
|
2021-11-23 20:00:41 -05:00
|
|
|
location ~ '\.(?:css|html|ico|js|json|map|svg|txt|wasm|xml)$' {
|
2021-07-06 13:53:00 -04:00
|
|
|
gzip_static on;
|
|
|
|
brotli_static on;
|
|
|
|
}
|
2021-06-18 05:21:42 -04:00
|
|
|
}
|
|
|
|
|
2023-05-22 17:47:52 -04:00
|
|
|
server {
|
|
|
|
listen 443 ssl http2;
|
|
|
|
listen [::]:443 ssl http2;
|
|
|
|
server_name mta-sts.matrix.grapheneos.org;
|
|
|
|
|
|
|
|
root /srv/mta-sts;
|
|
|
|
|
|
|
|
keepalive_timeout 0;
|
|
|
|
|
|
|
|
include snippets/security-headers.conf;
|
|
|
|
add_header Cross-Origin-Resource-Policy "same-origin" always;
|
|
|
|
|
|
|
|
location = / {
|
|
|
|
return 301 https://grapheneos.org/articles/grapheneos-servers;
|
|
|
|
}
|
|
|
|
|
|
|
|
location = /.well-known/mta-sts.txt {}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 404;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-24 13:52:50 -04:00
|
|
|
server {
|
2022-07-02 12:34:19 -04:00
|
|
|
listen unix:/run/nginx/status.sock;
|
2021-05-24 13:52:50 -04:00
|
|
|
|
2023-02-18 08:18:07 -05:00
|
|
|
access_log off;
|
|
|
|
|
2023-01-31 21:51:25 -05:00
|
|
|
location = / {
|
2021-05-24 13:52:50 -04:00
|
|
|
stub_status;
|
|
|
|
}
|
2021-06-22 23:43:32 -04:00
|
|
|
|
|
|
|
location / {
|
|
|
|
return 404;
|
|
|
|
}
|
2021-05-24 13:52:50 -04:00
|
|
|
}
|
|
|
|
}
|