nginx / chromeを使用したクロスオリジンリソースシェアリング(CORS)
次のセグメンテーションを使用したWebサイトがあります。 api.example.com developers.example.com example.com 両方を許可しexample.com、developers.example.comにAJAXリクエストを送信したいと思いますapi.example.com。 api.example.comユニコーンによって提供されているRackアプリであるのためのこれまでの私のnginx設定は、次のようになります。 upstream app_server { server unix:/tmp/api.example.com.sock fail_timeout=0; } server { listen 80; server_name api.example.com; access_log /home/nginx/api.example.com/log/access.log; error_log /home/nginx/api.example.com/log/error.log; location / { add_header 'Access-Control-Allow-Origin' 'http://example.com,http://developers.example.com'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Headers' 'Content-Type,Accept'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; …