nixos-config/config/services/reverse-proxy.nix

65 lines
2.2 KiB
Nix
Raw Normal View History

2022-04-25 18:09:22 +00:00
{ config, ... }: {
2022-04-15 08:27:53 +00:00
services.nginx.virtualHosts."hydra.chir.rs" = {
sslCertificate = "/var/lib/acme/chir.rs/cert.pem";
sslCertificateKey = "/var/lib/acme/chir.rs/key.pem";
locations."/" = {
proxyPass = "https://hydra.int.chir.rs";
2022-04-15 08:27:53 +00:00
proxyWebsockets = true;
2022-04-26 07:59:53 +00:00
extraConfig = ''
proxy_ssl_server_name on;
'';
2022-04-15 08:27:53 +00:00
};
};
2022-04-25 16:57:59 +00:00
services.nginx.virtualHosts."mastodon.chir.rs" = {
sslCertificate = "/var/lib/acme/chir.rs/cert.pem";
sslCertificateKey = "/var/lib/acme/chir.rs/key.pem";
locations."/" = {
2022-04-26 07:59:53 +00:00
proxyPass = "https://mastodon.int.chir.rs";
2022-04-25 16:57:59 +00:00
proxyWebsockets = true;
2022-04-26 07:59:53 +00:00
extraConfig = ''
proxy_ssl_server_name on;
'';
2022-04-25 16:57:59 +00:00
};
};
services.nginx.virtualHosts."mastodon-assets.chir.rs" = {
sslCertificate = "/var/lib/acme/chir.rs/cert.pem";
sslCertificateKey = "/var/lib/acme/chir.rs/key.pem";
locations."/" = {
tryFiles = "$uri @s3";
};
locations."@s3" = {
extraConfig = ''
limit_except GET {
deny all;
}
proxy_set_header Host 's3.us-west-000.backblazeb2.com';
2022-04-26 08:44:10 +00:00
set $s3_backend 'https://YOUR_BUCKET_NAME.YOUR_S3_HOSTNAME';
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;
2022-04-26 08:44:10 +00:00
proxy_pass $s3_backend$uri;
proxy_intercept_errors off;
proxy_cache CACHE;
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;
'';
};
};
2022-04-15 08:27:53 +00:00
}