LoginSignup
5
6

More than 3 years have passed since last update.

Nginxにhttpsへのリダイレクト設定する

Last updated at Posted at 2019-08-05

'Google Cloud Platform'で'wordpress with nginx and ssl certified by bitnami'をデプロイして、WordPressを運用する上で、httpからhttpsにリダイレクトする方法を記載します。

設定ファイルに記載する

bitnami.confに設定を書き込みます。

$ sudo vi /opt/bitnami/nginx/conf/bitnami/bitnami.conf

httpsリダイレクト設定

bitnami.conf
server {
    # httpをhttpsにリダイレクト
    listen 80;
    server_name hogehoge.com;
    return 301 https://$host$request_uri;
}

SSLv3を無効化

bitnami.conf
server {
    listen 443 ssl;
    server_name hogehoge.com;
    # SSLを無効化してTLSのみ受け付ける 
    ssl_protocols TLSv1.3 TLSv1.2;
}

設定を反映させる

Nginxを再起動して、設定を反映させます。

$ sudo /opt/bitnami/ctlscript.sh restart nginx

つまづきポイント

1. .htaccessを編集すれば良い!という情報がいっぱい

この設定ファイルはApache(以外にも?)というWebサーバーソフトウェアを使っているときに使う設定ファイルらしい(Apache以外にも使える?)。

2. /etc/nginx/nginx.confがない、そもそも/etc配下にnginxがない

これはbitnamiでNginxを入れたが故に。見つけられてよかった。

参考

ほとんどそのままです...
https://qiita.com/fisherman08/items/e39e67e85ef07a1ef3db
https://yusuke.blog/2017/12/20/2062

5
6
2

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
5
6