Nginx add headers PHP FPM returns an error -
i'm using laravel 4 nginx , php-fpm serving application.
the application implements api , i've added open cors rules nginx seem working fine.
whenever application throws error, nginx doesn't seem add headers part of response. there way force without having install more headers extension?
my config follows:
server { listen 80; server_name mediabase.local; root /home/vagrant/mediabase/public; index index.html index.htm index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; add_header access-control-allow-origin "*"; add_header access-control-allow-methods "get, options, post, head, delete, put"; add_header access-control-allow-headers "authorization, x-requested-with, content-type, origin, accept"; add_header access-control-allow-credentials "true"; add_header access-control-max-age: 86400; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/mediabase.local-error.log error; error_page 404 /index.php; sendfile off; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; add_header access-control-allow-origin "*"; add_header access-control-allow-methods "get, options, post, head, delete, put"; add_header access-control-allow-headers "authorization, x-requested-with, content-type, origin, accept"; add_header access-control-allow-credentials "true"; add_header access-control-max-age: 86400; } location ~ /\.ht { deny all; } }
nginx's docs say add_header
adds specified field response header provided the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307.
as alternative httpheadersmoremodule
can add headers in laravel, here how can done: https://stackoverflow.com/a/17550224
Comments
Post a Comment