Hi
I have this service where I proxy_pass a lot of different locations to different services.
All "locations" in this "server" need to have a lot of add_header lines for cors filtering.
But if I move the add_header from the "location" to the "server" section I get a:
nginx: [emerg] "add_header" directive is not allowed here in
Do I have to have all these "add_header" in each "location" or is there a trick I can do?
server {
listen 80;
server_name example.org;
location /foo {
root /var/www/nginx/html;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
# many lines here with "add_header"
return 204;
}
proxy_pass http://localhost:8080;
}
}
best regards
Hans
I have this service where I proxy_pass a lot of different locations to different services.
All "locations" in this "server" need to have a lot of add_header lines for cors filtering.
But if I move the add_header from the "location" to the "server" section I get a:
nginx: [emerg] "add_header" directive is not allowed here in
Do I have to have all these "add_header" in each "location" or is there a trick I can do?
server {
listen 80;
server_name example.org;
location /foo {
root /var/www/nginx/html;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
# many lines here with "add_header"
return 204;
}
proxy_pass http://localhost:8080;
}
}
best regards
Hans