From 41ea31a9ba8e603d6691043f8d41385f372514b4 Mon Sep 17 00:00:00 2001 From: fro Date: Thu, 30 Oct 2025 06:51:10 -0500 Subject: [PATCH] =?UTF-8?q?+=20/=20fw.op.fo=20=E2=9E=94=20wa.fo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cfg/ngx/wa.fo.conf | 88 ++++++++++++++++++++++++++++++ {cfg => obs/cfg}/ngx/fw.op.fo.conf | 0 2 files changed, 88 insertions(+) create mode 100644 cfg/ngx/wa.fo.conf rename {cfg => obs/cfg}/ngx/fw.op.fo.conf (100%) diff --git a/cfg/ngx/wa.fo.conf b/cfg/ngx/wa.fo.conf new file mode 100644 index 0000000..7907808 --- /dev/null +++ b/cfg/ngx/wa.fo.conf @@ -0,0 +1,88 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# configuration of wa.fo / frode klevstul / oct 2025 +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# sc.wa.fo & fw.wa.fo ➔ wa.fo +server { + listen 80; + server_name sc.wa.fo fw.wa.fo; + return 301 https://wa.fo$request_uri; +} + +server { + listen 443 ssl; + listen [::]:443 ssl; + http2 on; + + ssl_certificate /etc/nginx/acme.sh/wa.fo/fullchain.pem; + ssl_certificate_key /etc/nginx/acme.sh/wa.fo/key.pem; + ssl_trusted_certificate /etc/nginx/acme.sh/wa.fo/cert.pem; + + server_name sc.wa.fo fw.wa.fo; + return 301 https://wa.fo$request_uri; +} + +# http to https +server { + listen 80; + server_name wa.fo; + return 301 https://$host$request_uri; +} + +# upstream configuration for postgrest (used as reversed proxy) +upstream postgrest { + server localhost:3000; +} + +# https +server { + listen 443 ssl; + listen [::]:443 ssl; + http2 on; + + ssl_certificate /etc/nginx/acme.sh/wa.fo/fullchain.pem; + ssl_certificate_key /etc/nginx/acme.sh/wa.fo/key.pem; + ssl_trusted_certificate /etc/nginx/acme.sh/wa.fo/cert.pem; + + add_header Strict-Transport-Security "max-age=63072000" always; + + root /var/www/fw.wa.fo; + index index.html; + server_name fw.wa.fo; + + location @myownredirect { + return 302 /; + } + + # postgrest reverse proxy + location / { + error_page 404 = @myownredirect; + } + + # /dbg/shortcode | debug mode + location ~ ^/dbg/(\w+) { + default_type application/json; + proxy_hide_header Content-Location; + add_header Content-Location /rpc/$upstream_http_content_location; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_http_version 1.1; + proxy_pass http://postgrest/rpc/fwd?p_shortcode=$1&p_dbg=true; + } + + # /shortcode | normal mode + location ~ ^/([A-Za-z0-9]+) { + # https://stackoverflow.com/questions/53353572/proxy-pass-cannot-have-uri-part-in-location-given-by-regular-expression + rewrite ^/([A-Za-z0-9]+) /rpc/fwd break; + default_type application/json; + proxy_hide_header Content-Location; + add_header Content-Location /rpc/$upstream_http_content_location; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_http_version 1.1; + # note, that if writing 'post' (lowercase) instead of 'POST' (uppercase), that will lead to the postgrest error "cannot use the post method on rpc" + proxy_method POST; + # https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_body + proxy_set_body '{"p_shortcode": "$1", "p_dbg": "false"}'; + proxy_pass http://postgrest; + } + +} diff --git a/cfg/ngx/fw.op.fo.conf b/obs/cfg/ngx/fw.op.fo.conf similarity index 100% rename from cfg/ngx/fw.op.fo.conf rename to obs/cfg/ngx/fw.op.fo.conf