Browsed by
Category: NGINX

Adding CORS for NGINX Proxy

Adding CORS for NGINX Proxy

NGINX config example server { listen 80; server_name _; root /var/www; location / { try_files $uri @proxy_to_app; } location @proxy_to_app { # START CORS set $cors ‘on’; if ($request_method = OPTIONS) { set $cors “${cors}_options”; } # Allow CORS on preflight request if ($cors = ‘on_options’) { add_header ‘Access-Control-Allow-Origin’ ‘*’; add_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS’; # # Custom headers and headers various browsers *should* be OK with but aren’t # add_header ‘Access-Control-Allow-Headers’ ‘DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Origin,Accept’; # # Tell client that this pre-flight…

Read More Read More