Guest User

Untitled

a guest
Nov 3rd, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. server {
  2. server_name xy.com www.xy.com;
  3.  
  4. # Set the "Access-Control-Allow-Origin" header to allow any origin
  5. add_header 'Access-Control-Allow-Origin' '*';
  6.  
  7. # Allow the necessary HTTP methods and headers
  8. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  9. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  10. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  11.  
  12. # Additional CORS configurations if needed
  13.  
  14. root /var/www/html;
  15. index index.html;
  16.  
  17. location / {
  18. try_files $uri $uri/ =404;
  19.  
  20. proxy_pass http://127.0.0.1:3000; # Forward requests to your Node.js application
  21. proxy_http_version 1.1;
  22. proxy_set_header Upgrade $http_upgrade;
  23. proxy_set_header Connection 'upgrade';
  24. proxy_set_header Host $host;
  25. proxy_cache_bypass $http_upgrade;
  26. }
  27.  
  28. location ~* \.mjs$ {
  29. add_header Content-Type application/javascript;
  30. }
  31.  
  32. location ~* \.json$ {
  33. if ($request_method = 'OPTIONS') {
  34. add_header 'Access-Control-Allow-Origin' '*';
  35. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  36. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  37. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  38. add_header 'Access-Control-Max-Age' 1728000;
  39. add_header 'Content-Type' 'text/plain charset=UTF-8';
  40. add_header 'Content-Length' 0;
  41. return 204;
  42. }
  43.  
  44. add_header 'Access-Control-Allow-Origin' '*';
  45. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  46. add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
  47. add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
  48. }
  49.  
  50. listen 443 ssl; # managed by Certbot
  51. ssl_certificate /etc/letsencrypt/live/xy.com-0001/fullchain.pem; # managed by Certbot
  52. ssl_certificate_key /etc/letsencrypt/live/xy.com-0001/privkey.pem; # managed by Certbot
  53. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  54. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  55.  
  56. }
  57.  
  58. server {
  59. if ($host = www.xy.com) {
  60. return 301 https://$host$request_uri;
  61. }
  62.  
  63. if ($host = xy.com) {
  64. return 301 https://$host$request_uri;
  65. }
  66.  
  67. listen 80;
  68. server_name xy.com www.xy.com;
  69. return 404; # managed by Certbot
  70.  
  71.  
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment