Guest User

nginx.conf

a guest
Jan 9th, 2026
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. textserver {
  2. listen 80;
  3. server_name localhost;
  4. root /usr/share/nginx/html;
  5. index index.html;
  6.  
  7. # Serve Frontend
  8. location / {
  9. try_files $uri $uri/ /index.html;
  10. }
  11.  
  12. # Proxy API with Forced CORS Headers
  13. location /api/ {
  14. proxy_pass http://backend:3000;
  15.  
  16. proxy_http_version 1.1;
  17. proxy_set_header Upgrade $http_upgrade;
  18. proxy_set_header Connection 'upgrade';
  19. proxy_set_header Host $host;
  20. proxy_cache_bypass $http_upgrade;
  21.  
  22. # --- UPDATE THESE VALUES ---
  23. add_header 'Access-Control-Allow-Origin' 'http://<NAS_IP>:<PORT>' always;
  24. add_header 'Access-Control-Allow-Credentials' 'true' always;
  25. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
  26. add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always;
  27.  
  28. if ($request_method = 'OPTIONS') {
  29. add_header 'Access-Control-Allow-Origin' 'http://<NAS_IP>:<PORT>' always;
  30. add_header 'Access-Control-Allow-Credentials' 'true' always;
  31. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
  32. add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With' always;
  33. add_header 'Content-Length' 0;
  34. add_header 'Content-Type' 'text/plain charset=UTF-8';
  35. return 204;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment