search
LoginSignup
285
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Organization

nginx で http でのアクセスを https にリダイレクト

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

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

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

参考文献

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
What you can do with signing up
285
Help us understand the problem. What are the problem?