8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ELB配下に置いたredashサーバーのHTTPS化

Posted at

redashというよりnginxの設定の話です

構成

  • https://redash.io/help/open-source/setup に載っているAMIを使ってセットアップしたRedash (Ubuntu 16.04)
  • Elastic Load Balancer経由でバックエンドの80番ポートに接続、ELB側は443のみ許可
  • ACMで取得したSSL証明書をELBにインストール

起きていた問題

  • https://redash.example.comに接続しようとすると、http://redash.example.com?next=http://redash.example.com/login にリダイレクトされてしまった

やったこと

  • /etc/nginx/site-available/redash を変更
upstream rd_servers {
  server 127.0.0.1:5000;
}

server {

  server_tokens off;

  listen 80 default;
  server_name redash.example.com;
  if ($http_x_forwarded_proto = 'http') {
     return 301 https://$server_name$request_uri;
  }

  access_log /var/log/nginx/rd.access.log;

  gzip on;
  gzip_types *;
  gzip_proxied any;

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_pass       http://rd_servers;
  }
}
  • redashを再起動
$ sudo nginx -s reload

主にやったこと

  server_name redash.example.com;
  if ($http_x_forwarded_proto = 'http') {
     return 301 https://$server_name$request_uri;
  }
  • proxy_set_header の値を変更
    • $schemeのままだと常にhttpが入ってしまっているので、$http_x_forwarded_protoを使うことでELBから転送された元のプロトコル(https)をセットするようにする。
- proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
8
6
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
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?