Skip to content

Instantly share code, notes, and snippets.

@ykrkn
Created August 27, 2013 12:53
Show Gist options
  • Save ykrkn/6353117 to your computer and use it in GitHub Desktop.
Save ykrkn/6353117 to your computer and use it in GitHub Desktop.
nginx CORS configuration
location /api {
proxy_pass http://localhost:8080/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin *;
if ($request_method = OPTIONS ) {
add_header Allow 'POST, GET, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers 'accept, origin, content-type';
add_header Access-Control-Allow-Methods 'POST, GET, PUT, DELETE, OPTIONS';
return 200;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment