LoginSignup
0
0

More than 3 years have passed since last update.

Elastic CloudのKibanaをnginxでリバースプロキシする

Posted at

概要

自ドメインとして扱いたかったため

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関連のヘッダは用途により要調整

0
0
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
0
0