Nginx将http重新编号为https

时间:2016-04-14 22:18:27

标签: redirect nginx

我需要将所有http请求重定向到nginx中的https,并使用一些自生成的SSL证书(使用opensssl),但我的配置有问题:

server {
  listen      80;
  server_name x.x.x.x;

  # 301 = permanent redirect, 302 = temporary redirect
  #return 301  https://x.x.x.x;
 return 301 https://$host$request_uri;
}


server {
        listen  443 ssl;
        server_name x.x.x.x;

        root /usr/share/nginx/html;
        index index.html index.htm;

        ssl on;
        ssl_certificate /etc/nginx/ssl/server.crt;
        ssl_certificate_key /etc/nginx/ssl/server.key; 
}

0 个答案:

没有答案