始终对域使用https?

时间:2015-10-04 14:51:43

标签: ssl amazon-web-services nginx amazon-ec2

我刚刚在ec2,ubuntu和nginx上建立了一个服务器,并通过namecheap(也提供我的域名)设置了ssl证书。

当我点击https://example.com时,证书就会出现。

如何让用户点击www.example.com或http://example.com他们使用https://连接?

1 个答案:

答案 0 :(得分:3)

我认为以下内容应该有效:

server {
  server_name example.com;
  listen 443 ssl default_server;
  # your https-specific config 
}

server {
  server_name example.com;
  listen 80;
  location / {
    return 301 https://example.com$request_uri;
  }
}
相关问题