Skip to content

Instantly share code, notes, and snippets.

@eiichi-worker
Last active January 25, 2018 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiichi-worker/51417f7737ecc9ffe7b32cdbc5148cea to your computer and use it in GitHub Desktop.
Save eiichi-worker/51417f7737ecc9ffe7b32cdbc5148cea to your computer and use it in GitHub Desktop.
[WIP] PrivateなネットワークにあるElasticsearchServiceにパブリックにつなぎたい AWS

やりたいこと

PrivateなネットワークにあるElasticsearchServiceにパブリックにつなぎたい。

アプローチ

パブリックなVPC(ElasticsearchServiceにinternalに繋がる)にプロキシ立てる

環境

プロキシサーバ
 AWS
  Amazon Linux 2
   nginx

構築

nginx入れる

sudo amazon-linux-extras install nginx1.12
nginx -v

# 自動起動
sudo systemctl enable nginx.service
 
# 起動
sudo systemctl start nginx.service

プロキシ設定 /etc/nginx/conf.d/proxy.conf

server{
    server_name    proxy-es.example.com;
    listen 80;

    proxy_set_header    Host    $host;
    proxy_set_header    X-Real-IP    $remote_addr;
    proxy_set_header    X-Forwarded-Host       $host;
    proxy_set_header    X-Forwarded-Server    $host;
    proxy_set_header    X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_read_timeout 120; # 重めなクエリ回したりする時はtimeout伸ばしておくと良い

    location / {
        proxy_pass    http://es.example.com/;
    }

}

再起動

sudo systemctl restart nginx.service

以下にアクセスでキバナが見れるはず
http://proxy-es.example.com/_plugin/kibana/app/kibana

セキュリティ的に

  • ベーシック認証かける
  • 特定IPのみ許可する
    とかしておくほうが良い。

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment