Как вернуть cors при 503 статусе в nginx
Необходимо установить определенные CORS к 503 ответу в nginx. Пробую так но увы не работает:
listen 80;
listen 443 ssl http2;
server_name www.example.com;
root www.example.com/public;
index index.php index.html;
# redirect from http to https
if ($ssl_protocol = "") {
rewrite ^/(.*) https://$server_name/$1 permanent;
}
ssl_certificate example.crt;
ssl_certificate_key example.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
try_files $uri $uri/ /index.html /index.php?$query_string;
error_page 503 /index.html;
location = /index.html {
root www.example.com/public;
expires -1;
}
if (-f $document_root/index.html) { return 503; }
if ($status = 503) {
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}