概要
自ドメインとして扱いたかったため
Tips
- kibana_alias_domainに自分のドメイン
- kibana_hostにElastic Cloudのエンドポイント
コード
server {
listen 80;
server_name {{ kibana_alias_domain }};
location / {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE';
add_header Access-Control-Allow-Headers 'Origin, Authorization, Accept, Content-Type, cache-control, X-CSRF-TOKEN, kbn-xsrf';
add_header Access-Control-Allow-Credentials 'true';
return 204;
}
proxy_pass {{ kibana_host }};
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE';
add_header Access-Control-Allow-Headers 'Origin, Authorization, Accept, Content-Type, cache-control, X-CSRF-TOKEN, kbn-xsrf';
add_header Access-Control-Allow-Credentials 'true';
rewrite /(.*)$ /$1 break;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
CORS関連のヘッダは用途により要調整