0
1

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.

nginxで強制的にhttpsにする

Posted at

httpsが必須になってきた昨今、nginxでhttpのアクセスをhttpsにリダイレクトさせることがよくあるけどよく忘れるのでメモ。(※証明書はlet's encryptで取得済みの前提)

xxx.comの部分は設定するドメインに変更。

server {
    listen 80;
    server_name xxx.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    ssl on;
    ssl_certificate     /etc/letsencrypt/live/xxx.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/xxx.com/privkey.pem;

    server_name xxx.com;

    # ...etc..
}

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?