map $http_origin $cors_header{ default ""; include /etc/nginx/sites-whitelist/bubblesocket_whitelist.map; } server { listen 80; listen [::]:80; server_name ~^(?.+)\.bubblesocket$ bubblesocket; access_log /var/log/nginx/bubblesocket.access.log; error_log /var/log/nginx/bubblesocket.error.log; location / { #include snippets/disable-cors.conf; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$cors_header'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, 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-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } proxy_pass http://127.0.0.1:29176/$protocol; proxy_hide_header Access-Control-Allow-Origin; add_header 'Access-Control-Allow-Origin' "$cors_header" always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, X-Auth-Token'; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; include snippets/self-signed.conf; server_name ~^(?.+)\.bubblesocket$ bubblesocket; access_log /var/log/nginx/bubblesocket.access.log; error_log /var/log/nginx/bubblesocket.error.log; location / { #include snippets/disable-cors.conf; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$cors_header'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, 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-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } proxy_pass http://127.0.0.1:29176/$protocol; proxy_hide_header Access-Control-Allow-Origin; add_header 'Access-Control-Allow-Origin' "$cors_header" always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, X-Auth-Token'; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; } }