library/roles/nginx: Add a snippet to enable CORS.
This commit is contained in:
parent
3a6f0675f5
commit
64f8947dd5
|
@ -15,6 +15,7 @@ nginx_conf_snippets:
|
|||
- letsencrypt-proxy.conf
|
||||
- nginx-proxy-params.conf
|
||||
- nginx-server-ssl.conf
|
||||
- nginx-cors.conf
|
||||
|
||||
nginx_old_snippets:
|
||||
- compression.conf
|
||||
|
@ -55,6 +56,8 @@ nginx_proxy_send_timeout: 120s
|
|||
nginx_client_max_body_size: 32000M
|
||||
nginx_client_body_timeout: 240s
|
||||
|
||||
nginx_cors_acl_origin: 'http?://(localhost)'
|
||||
|
||||
# Find a set of acceptable defaults for the cache setup
|
||||
nginx_cache_enabled: False
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# set $cors '';
|
||||
# if ($http_origin ~* '{{ nginx_cors_acl_origin }}') {
|
||||
# set $cors 'true';
|
||||
# }
|
||||
# if ($cors = 'true') {
|
||||
add_header 'Access-Control-Allow-Origin' "$http_origin";
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With';
|
||||
# }
|
||||
if ($request_method = 'OPTIONS') {
|
||||
return 204;
|
||||
}
|
Loading…
Reference in New Issue