# Nginx Configuration for LittleShop on Hostinger VPS # Place this file in /etc/nginx/sites-available/littleshop # Then link it: ln -s /etc/nginx/sites-available/littleshop /etc/nginx/sites-enabled/ # Upstream backend server upstream littleshop_backend { server localhost:8080; keepalive 32; } # HTTP Server - Redirect to HTTPS server { listen 80; listen [::]:80; server_name littleshop.silverlabs.uk thebankofdebbie.giize.com srv1002428.hstgr.cloud; # Redirect all HTTP traffic to HTTPS return 301 https://$server_name$request_uri; } # HTTPS Server server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name littleshop.silverlabs.uk thebankofdebbie.giize.com srv1002428.hstgr.cloud; # SSL Configuration ssl_certificate /etc/letsencrypt/live/littleshop.silverlabs.uk/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/littleshop.silverlabs.uk/privkey.pem; # SSL Security Settings ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers off; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1d; ssl_stapling on; ssl_stapling_verify on; # Security Headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; # Request size limits client_max_body_size 50M; client_body_buffer_size 128k; # Timeouts proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; send_timeout 60s; # Logging access_log /var/log/nginx/littleshop_access.log combined; error_log /var/log/nginx/littleshop_error.log error; # Root location - Proxy to LittleShop location / { proxy_pass http://littleshop_backend; proxy_http_version 1.1; # Headers for proper forwarding 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 X-Forwarded-Port $server_port; # WebSocket support for SignalR/Blazor proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; # Disable buffering for SSE/streaming proxy_buffering off; proxy_cache off; } # Static files (if needed) location /uploads { alias /opt/littleshop/wwwroot/uploads; expires 30d; add_header Cache-Control "public, immutable"; } # Health check endpoint location /health { proxy_pass http://littleshop_backend/api/test/database; access_log off; } # SilverPAY webhook - allow without auth location /api/silverpay/webhook { proxy_pass http://littleshop_backend/api/silverpay/webhook; 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; # Allow SilverPAY IPs only (add actual IPs) # allow 31.97.57.205; # deny all; } # Admin area - additional security location /Admin { proxy_pass http://littleshop_backend/Admin; 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; # Optional: IP restrictions for admin area # allow 192.168.1.0/24; # allow 10.0.0.0/8; # deny all; } # Blazor SignalR hub location /_blazor { proxy_pass http://littleshop_backend/_blazor; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; # Important for SignalR proxy_buffering off; proxy_read_timeout 3600s; proxy_send_timeout 3600s; } # API documentation (Swagger) location /swagger { proxy_pass http://littleshop_backend/swagger; 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; } }