2024-05-08 17:47:47 +00:00
|
|
|
{ config, ... }:
|
2023-10-28 15:21:54 +00:00
|
|
|
|
|
|
|
let
|
2024-10-15 21:19:02 +00:00
|
|
|
objStorHost = "mastodon.web.pub.solar";
|
2023-10-28 15:21:54 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
services.nginx.virtualHosts = {
|
2024-05-08 17:47:47 +00:00
|
|
|
"files.${config.pub-solar-os.networking.domain}" = {
|
2023-10-28 15:21:54 +00:00
|
|
|
enableACME = true;
|
2023-10-28 15:56:55 +00:00
|
|
|
forceSSL = true;
|
2023-10-28 15:21:54 +00:00
|
|
|
|
2024-10-15 21:19:02 +00:00
|
|
|
# Use variable to force nginx to perform a DNS resolution on its value,
|
|
|
|
# the IP of the object storage provider may not always remain the same.
|
|
|
|
extraConfig = ''
|
|
|
|
set $s3_backend 'https://${objStorHost}';
|
|
|
|
'';
|
|
|
|
|
2023-10-28 15:21:54 +00:00
|
|
|
locations = {
|
|
|
|
"= /" = {
|
|
|
|
index = "index.html";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/" = {
|
|
|
|
tryFiles = "$uri @s3";
|
|
|
|
};
|
|
|
|
|
|
|
|
"@s3" = {
|
|
|
|
extraConfig = ''
|
|
|
|
limit_except GET {
|
|
|
|
deny all;
|
|
|
|
}
|
|
|
|
|
2023-10-28 20:15:40 +00:00
|
|
|
proxy_set_header Host ${objStorHost};
|
2023-10-28 15:21:54 +00:00
|
|
|
proxy_set_header Connection \'\';
|
|
|
|
proxy_set_header Authorization \'\';
|
|
|
|
proxy_hide_header Set-Cookie;
|
|
|
|
proxy_hide_header 'Access-Control-Allow-Origin';
|
|
|
|
proxy_hide_header 'Access-Control-Allow-Methods';
|
|
|
|
proxy_hide_header 'Access-Control-Allow-Headers';
|
|
|
|
proxy_hide_header x-amz-id-2;
|
|
|
|
proxy_hide_header x-amz-request-id;
|
|
|
|
proxy_hide_header x-amz-meta-server-side-encryption;
|
|
|
|
proxy_hide_header x-amz-server-side-encryption;
|
|
|
|
proxy_hide_header x-amz-bucket-region;
|
|
|
|
proxy_hide_header x-amzn-requestid;
|
|
|
|
proxy_ignore_headers Set-Cookie;
|
2024-10-15 21:19:02 +00:00
|
|
|
proxy_pass $s3_backend$uri;
|
2023-10-28 15:21:54 +00:00
|
|
|
proxy_intercept_errors off;
|
2023-10-28 20:52:57 +00:00
|
|
|
proxy_ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
proxy_ssl_server_name on;
|
2023-10-28 15:21:54 +00:00
|
|
|
|
2023-10-28 19:12:33 +00:00
|
|
|
proxy_cache cache;
|
2023-10-28 15:21:54 +00:00
|
|
|
proxy_cache_valid 200 48h;
|
|
|
|
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
|
|
|
proxy_cache_lock on;
|
|
|
|
|
|
|
|
expires 1y;
|
|
|
|
add_header Cache-Control public;
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
|
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
|
|
add_header X-Content-Type-Options nosniff;
|
|
|
|
add_header Content-Security-Policy "default-src 'none'; form-action 'none'";
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|