← back to Kamatera Nginx

sites-available/claimmyaddress.com.conf

47 lines

# HTTP → HTTPS redirect
server {
    listen 80;
    server_name claimmyaddress.com www.claimmyaddress.com;
    return 301 https://$host$request_uri;
}

# HTTPS → Next.js
server {
    listen 443 ssl http2;
    server_name claimmyaddress.com www.claimmyaddress.com;

    ssl_certificate /etc/letsencrypt/live/claimmyaddress.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/claimmyaddress.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    # Security headers
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "geolocation=(self), microphone=(), camera=()" always;

    # Site Factory routes (Stripe + auth + health + webhook + claim) → SF port 3003
    location ~ ^/api/(auth|checkout|health|webhook|claim)(/|$) {
        proxy_pass http://127.0.0.1:3003;
        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_http_version 1.1;
        # Stripe webhook sig verify needs raw body
        proxy_request_buffering off;
    }

    # Everything else → pastdoor (port 9821)
    location / {
        proxy_pass http://127.0.0.1:9821;
        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_http_version 1.1;
    }
}