progmaweb
The site and account service of Progmasoft: a Next.js frontend and an ASP.NET Core API.
Clonegit clone https://git.progmasoft.com/progmaweb
Activate the account.progmasoft.com production host with dedicated HTTP and TLS virtual servers, ACME-compatible certificate routing, security headers, and loopback proxy forwarding. Correct the host-aware Next.js account landing rewrite so public HTTPS termination at Nginx does not cause the HTTP-only Next listener to receive an invalid TLS connection. Verified formatting, ESLint, generated route types, TypeScript checks, production frontend build, live Nginx syntax, Cloudflare DNS publication, and the expanded Let's Encrypt SAN set.
- Commit
1ce38648d6e987aaaa06d7d4fff461ef862f9a93- Author
- Leitwolf11 ·
- Parents
f92a585d831c
Changes
apps/web/proxy.ts | 8 +++++++- ops/nginx/progmaweb.conf | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/apps/web/proxy.ts b/apps/web/proxy.ts index ba42e70..42249a2 100644 --- a/apps/web/proxy.ts +++ b/apps/web/proxy.ts @@ -10,7 +10,13 @@ export function proxy(request: NextRequest) { // The account root has its own landing page, but authentication and dashboard URLs remain stable and readable. if (accountHosts.has(host) && pathname === "/") { - return NextResponse.rewrite(new URL("/account", request.url)); + const destination = new URL("/account", request.url); + + // TLS terminates at Nginx. Next derives the public scheme from X-Forwarded-Proto, + // so an unmodified absolute rewrite would attempt TLS against its HTTP-only + // loopback listener and fail before the account page can render. + destination.protocol = "http:"; + return NextResponse.rewrite(destination); } // Corporate hosts must not accidentally expose the account-only landing page as a public navigation destination. diff --git a/ops/nginx/progmaweb.conf b/ops/nginx/progmaweb.conf index 31d84e5..8f9c071 100644 --- a/ops/nginx/progmaweb.conf +++ b/ops/nginx/progmaweb.conf @@ -13,6 +13,21 @@ server { } } +server { + listen 80; + listen [::]:80; + server_name account.progmasoft.com; + + location ^~ /.well-known/acme-challenge/ { + root /var/lib/letsencrypt; + default_type text/plain; + } + + location / { + return 301 https://account.progmasoft.com$request_uri; + } +} + server { listen 443 ssl; listen [::]:443 ssl; @@ -57,3 +72,35 @@ server { proxy_read_timeout 60s; } } + +server { + listen 443 ssl; + listen [::]:443 ssl; + http2 on; + server_name account.progmasoft.com; + + ssl_certificate /etc/letsencrypt/live/progmasoft.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/progmasoft.com/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + + client_max_body_size 1m; + + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "DENY" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always; + + location / { + proxy_pass http://127.0.0.1:3010; + proxy_http_version 1.1; + proxy_set_header Host $host; + 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 $scheme; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_read_timeout 60s; + } +}