327
286

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 で http でのアクセスを https にリダイレクト

Last updated at Posted at 2014-02-14

ちょっと検索するとrewriteするやり方が結構出てくるのだけど色々見てたらreturnを使う方法がシンプルだったので採用してみた。正規表現とかifとか出てこないのでわかりやすい。

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

server {
    listen 443;
    ssl on;
    # ...
}

参考文献

327
286
5

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
327
286

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?