# Example nginx config for nip05api. # Replace example.com with your DOMAIN. upstream nip05api { server 127.0.0.1:8080; keepalive 16; } # HTTP → HTTPS redirect (assumes certbot or equivalent has terminated TLS). server { listen 80; listen [::]:80; server_name example.com; return 301 https://$host$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers off; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1d; # HSTS — opt in once you're confident HTTPS is permanent. # 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; client_max_body_size 1m; # NIP-05 well-known endpoint MUST be served on the apex domain. location = /.well-known/nostr.json { proxy_pass http://nip05api; 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; proxy_set_header Connection ""; add_header Access-Control-Allow-Origin "*" always; add_header Cache-Control "public, max-age=60" always; } location ~ ^/(v1/|healthz|version|openapi.json|docs) { proxy_pass http://nip05api; 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; proxy_set_header Connection ""; proxy_read_timeout 30s; } }