map $http_origin $roguelike_cors_header { default ""; include /etc/nginx/sites-whitelist/roguelike.map; } server { listen 80; listen [::]:80; access_log /var/log/nginx/roguelike.access.log; error_log /var/log/nginx/roguelike.error.log; server_name roguelike roguelike.eyeofmidas.net; root /var/www/roguelike/wwwroot; #server_name roguelike.eyeofmidas.net; #return 302 https://$server_name$request_uri; location / { try_files $uri $uri/ =404; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; include snippets/self-signed.conf; access_log /var/log/nginx/roguelike.access.log; error_log /var/log/nginx/roguelike.error.log; server_name roguelike roguelike.eyeofmidas.net; root /var/www/roguelike/wwwroot; location / { try_files $uri $uri/ =404; } } server { listen 8080; listen [::]:8080; access_log /var/log/nginx/roguelike.access.log; error_log /var/log/nginx/roguelike.error.log; server_name roguelike roguelike.eyeofmidas.net; #server_name roguelike.eyeofmidas.net; #return 302 https://$server_name$request_uri; location / { #include snippets/disable-cors.conf; if ($request_method = 'OPTIONS') { add_header X-debug-message 'origin: $http_origin cors: $roguelike_cors_header' always; add_header 'Access-Control-Allow-Origin' '$roguelike_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:5084; proxy_hide_header Access-Control-Allow-Origin; add_header 'Access-Control-Allow-Origin' "$roguelike_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'; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; include snippets/self-signed.conf; access_log /var/log/nginx/roguelike.access.log; error_log /var/log/nginx/roguelike.error.log; server_name roguelike roguelike.eyeofmidas.net; location / { #include snippets/disable-cors.conf; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$roguelike_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:5084; proxy_hide_header Access-Control-Allow-Origin; add_header 'Access-Control-Allow-Origin' "$roguelike_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'; } }