Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server {
- server_name xy.com www.xy.com;
- # Set the "Access-Control-Allow-Origin" header to allow any origin
- add_header 'Access-Control-Allow-Origin' '*';
- # Allow the necessary HTTP methods and headers
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
- # Additional CORS configurations if needed
- root /var/www/html;
- index index.html;
- location / {
- try_files $uri $uri/ =404;
- proxy_pass http://127.0.0.1:3000; # Forward requests to your Node.js application
- 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;
- }
- location ~* \.mjs$ {
- add_header Content-Type application/javascript;
- }
- location ~* \.json$ {
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain charset=UTF-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
- }
- listen 443 ssl; # managed by Certbot
- ssl_certificate /etc/letsencrypt/live/xy.com-0001/fullchain.pem; # managed by Certbot
- ssl_certificate_key /etc/letsencrypt/live/xy.com-0001/privkey.pem; # managed by Certbot
- include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
- ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
- }
- server {
- if ($host = www.xy.com) {
- return 301 https://$host$request_uri;
- }
- if ($host = xy.com) {
- return 301 https://$host$request_uri;
- }
- listen 80;
- server_name xy.com www.xy.com;
- return 404; # managed by Certbot
- }
Advertisement
Add Comment
Please, Sign In to add comment