Open CORS config.
parent
b1a6f7df33
commit
a1ffe39318
|
@ -47,14 +47,41 @@ upstream backend_snipt {
|
|||
}
|
||||
|
||||
location / {
|
||||
|
||||
# Open CORS config from https://gist.github.com/michiel/1064640.
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Content-Type' 'text/plain charset=UTF-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'POST') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Credentials' 'true';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
||||
}
|
||||
|
||||
rewrite_by_lua '
|
||||
if string.find(ngx.var.host, "_") then
|
||||
local newHost, n = ngx.re.gsub(ngx.var.host, "_", "-")
|
||||
ngx.redirect(ngx.var.scheme .. "://" .. newHost .. ngx.var.uri)
|
||||
end
|
||||
';
|
||||
|
||||
proxy_pass http://backend_snipt;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
|
|
Loading…
Reference in New Issue