From 6d070ef4cc18c6699efafedcdbedb72dc0bd2fdf Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Sun, 31 Mar 2024 16:35:39 -0700 Subject: [PATCH 1/3] Revert "Use wasabi instead of linode" This reverts commit d9ccdc2141ce140676fc3a8644585da2882460c4. --- misskey-service.nix | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/misskey-service.nix b/misskey-service.nix index c064486..d152dfb 100644 --- a/misskey-service.nix +++ b/misskey-service.nix @@ -100,18 +100,11 @@ in { ''; locations."/".extraConfig = '' - # set $bucket rub-um5oh2ac4yi9c2mf.misskey.egirls.gay; - # set $region us-east-1; - # set $url linodeobjects.com; - set $bucket egirls-gay-misskey; - set $region us-west-1; - set $url wasabisys.com; - set $path /egirls-gay-misskey/; + set $bucket rub-um5oh2ac4yi9c2mf.misskey.egirls.gay; + set $region us-east-1; - #proxy_pass https://storage.us-east-1.linodeobjects.com; - #proxy_set_header Host $bucket.us-east-1.linodeobjects.com; - proxy_pass https://$bucket.$region.$url$path; - proxy_set_header Host $bucket.$region.$url$path; + proxy_pass https://storage.us-east-1.linodeobjects.com; + proxy_set_header Host $bucket.us-east-1.linodeobjects.com; proxy_http_version 1.1; proxy_redirect off; proxy_intercept_errors on; From 663482244b91056652215aa9f1517398f7873553 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Mon, 15 Apr 2024 09:26:03 -0700 Subject: [PATCH 2/3] nix flake update --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index ab5b11d..ed2f6d2 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1709309926, - "narHash": "sha256-VZFBtXGVD9LWTecGi6eXrE0hJ/mVB3zGUlHImUs2Qak=", + "lastModified": 1713013257, + "narHash": "sha256-ZEfGB3YCBVggvk0BQIqVY7J8XF/9jxQ68fCca6nib+8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "79baff8812a0d68e24a836df0a364c678089e2c7", + "rev": "90055d5e616bd943795d38808c94dbf0dd35abe8", "type": "github" }, "original": { @@ -41,11 +41,11 @@ }, "unstable": { "locked": { - "lastModified": 1709237383, - "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "lastModified": 1712963716, + "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", "type": "github" }, "original": { From 70067f82f7467b84f16b3bef19a3c5ed60028d61 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Mon, 15 Apr 2024 21:52:34 -0700 Subject: [PATCH 3/3] Use wasabi instead of linode, with caching --- misskey-service.nix | 56 +++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/misskey-service.nix b/misskey-service.nix index d152dfb..c764787 100644 --- a/misskey-service.nix +++ b/misskey-service.nix @@ -84,11 +84,19 @@ in { in { enable = true; recommendedProxySettings = true; + package = pkgs.openresty; upstreams."misskey".extraConfig = '' server unix:/var/run/misskey/misskey.sock; ''; + proxyCachePath."egirls_media_cache" = { + enable = true; + maxSize = "1g"; + inactive = "10m"; + keysZoneName = "egirls_media_cache"; + }; + virtualHosts."media.egirls.gay" = { inherit listen; @@ -97,28 +105,42 @@ in { extraConfig = '' client_max_body_size 1m; + proxy_cache media_cache; + proxy_cache_valid 200 10m; + proxy_cache_lock on; + + proxy_ignore_headers X-Accel-Expires Expires Cache-Control; + proxy_hide_header X-Amz-ID-2; + proxy_hide_header X-Amz-Request-ID; + proxy_hide_header X-Wasabi-CM-Reference-ID; + + proxy_hide_header Set-Cookie; + proxy_ignore_headers Set-Cookie; ''; locations."/".extraConfig = '' - set $bucket rub-um5oh2ac4yi9c2mf.misskey.egirls.gay; - set $region us-east-1; - - proxy_pass https://storage.us-east-1.linodeobjects.com; - proxy_set_header Host $bucket.us-east-1.linodeobjects.com; - proxy_http_version 1.1; - proxy_redirect off; - proxy_intercept_errors on; - error_page 400 401 403 404 406 409 410 /404; - - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto https; - - proxy_cache off; + return 404; ''; - locations."/404".extraConfig = '' - return 404 "not found"; + locations."/misskey/".extraConfig = '' + proxy_http_version 1.1; + + include /etc/nixos-secrets/s3-access-nginx.conf; + + set $s3_bucket 'egirls-gay-misskey'; + set $path_full '/$s3_bucket$request_uri'; + + set_by_lua $now "return ngx.http_time(ngx.time())"; + set $signature_string "GET\n\n\n\nx-amz-date:''${now}\n$path_full"; + set_hmac_sha1 $s3_signature $s3_secret $signature_string; + set_encode_base64 $s3_signature_b64 $s3_signature; + + proxy_set_header x-amz-date $now; + proxy_set_header Authorization "AWS $s3_access:$s3_signature_b64"; + + proxy_ssl_session_reuse on; + rewrite .* $path_full break; + proxy_pass https://s3.us-west-1.wasabisys.com; ''; };