2
3

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.

HTTPSのリスナーをもつELBにWordpressのインスタンスをぶらさげるときのTIPS

Last updated at Posted at 2019-01-18

AWS上でALBの下にWordpressのインスタンスをぶらさげようとしてちょっとはまったのでメモ

  • 構成
    • EC2(Amazon Linux 2) + RDS(MySQL) + ALB というごくごくふつうの構成
  • はまった点
    • ふつうにHTTPSのリスナーをもつALB配下にWordpressをいれたEC2をぶらさげたら、インストール画面がHTTPのみのときとなんか違う
    • Chromeのデベロッパーツールでのぞいてみたら mixed content の山になっていた
    • どうやらCSSとかをHTTPで返してくるようだ
  • 解決策
    • ALB(CLBでもいっしょだけど)から転送されてきたときの HTTP_X_FORWARDED_PROTO を見て $_SERVER['HTTPS'] $_ENV['HTTPS']on にしてやればいいみたい
    • wp-config.php に下記の構文を入れる
if($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
  $_SERVER['HTTPS'] = 'on';
  $_ENV['HTTPS'] = 'on';
}

以上です

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?