mirror of
https://github.com/joglomedia/LEMPer.git
synced 2026-04-05 12:18:19 +00:00
added CORS rules
This commit is contained in:
38
etc/nginx/includes/cors.conf
Normal file
38
etc/nginx/includes/cors.conf
Normal file
@@ -0,0 +1,38 @@
|
||||
# Enable CORS
|
||||
|
||||
# Allow cross-origin requests.
|
||||
#
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
|
||||
# https://enable-cors.org/
|
||||
# https://www.w3.org/TR/cors/
|
||||
|
||||
# (!) Do not use this without understanding the consequences.
|
||||
# This will permit access from any other website.
|
||||
# Instead of using this file, consider using a specific rule such as
|
||||
# allowing access based on (sub)domain:
|
||||
#
|
||||
# add_header Access-Control-Allow-Origin "subdomain.example.com";
|
||||
|
||||
# Simple requests
|
||||
if ($request_method ~* "(GET|POST)") {
|
||||
# Wildcard allow all origin
|
||||
#add_header Access-Control-Allow-Origin "*";
|
||||
add_header Access-Control-Allow-Origin $cors;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, HEAD";
|
||||
add_header Access-Control-Expose-Headers "Content-Length, Content-Range";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Origin, DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept, Range";
|
||||
}
|
||||
|
||||
# Pre-flighted requests
|
||||
if ($request_method = OPTIONS) {
|
||||
# Wildcard allow all origin
|
||||
#add_header Access-Control-Allow-Origin "*";
|
||||
add_header Access-Control-Allow-Origin $cors;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, HEAD";
|
||||
add_header Access-Control-Allow-Headers "Authorization, Origin, DNT, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept, Range";
|
||||
add_header Access-Control-Max-Age 1728000;
|
||||
add_header Content-Type "text/plain; charset=utf-8";
|
||||
add_header Content-Length 0;
|
||||
|
||||
return 200;
|
||||
}
|
||||
Reference in New Issue
Block a user