LoginSignup
6
5

More than 5 years have passed since last update.

nginxでステータス200以外でもヘッダーを付けたい

Last updated at Posted at 2016-03-09

nginxでレスポンスコード200以外(4xxとか5xx)でもレスポンスヘッダーを付けたいことありますよね。

そんな時、always を付与すると、ステータスコードにかかわらずレスポンスヘッダーを付与することが出来ます。

add_header 'Access-Control-Allow-Origin' '*' always;

対応バージョン

1.7.5移行であれば利用できるようです。
http://nginx.org/en/docs/http/ngx_http_headers_module.html

非対応バージョン

headers-more-nginx-moduleを利用すると実現できそうです。
https://github.com/openresty/headers-more-nginx-module#synopsis

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5