From 16860f04bb4f71ce98d4e0938e8a8bcf0bac4a7b Mon Sep 17 00:00:00 2001 From: toufic ar Date: Tue, 15 Sep 2026 17:36:06 +0300 Subject: ntfy-sh follow proxy config suggests --- adonis/push/default.nix | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'adonis') diff --git a/adonis/push/default.nix b/adonis/push/default.nix index 041ed1f..cc2eff3 100644 --- a/adonis/push/default.nix +++ b/adonis/push/default.nix @@ -3,11 +3,19 @@ ntfyPort = "8080"; mollyPort = "8020"; nginxConf = '' - proxy_set_header Host $host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_buffering off; + proxy_request_buffering off; + proxy_redirect off; + proxy_connect_timeout 3m; + proxy_send_timeout 3m; + proxy_read_timeout 3m; + client_max_body_size 0; ''; in { sops.secrets = { @@ -41,7 +49,19 @@ in { enableACME = true; locations."/" = { proxyPass = "http://127.0.0.1:${ntfyPort}"; - extraConfig = nginxConf; + extraConfig = '' + set $redirect_https ""; + if ($request_method = GET) { + set $redirect_https "yes"; + } + if ($request_uri ~* "^/([-_a-z0-9]{0,64}$|docs/|static/)") { + set $redirect_https "''${redirect_https}yes"; + } + if ($redirect_https = "yesyes") { + return 302 https://$http_host$request_uri$is_args$query_string; + } + ${nginxConf} + ''; }; }; -- cgit v1.3.1