nginx 配置https和http跳转https

#http自动跳https
    server{
    listen 80;
    server_name www.yourname.com alias yourname.com;
    return 301 https://$server_name$request_uri;
    }
    server
    {
    #listen 80;
    listen 443 ssl;
    #rewrite ^(.*) https://$host$1 permanent;
    server_name www.yourname.com yourname.com;
    #return 301 https://$server_name$request_uri;
    index index.blade.php index.htm index.php;
    root  /var/www/project/public;
    error_page 404 503 403 500 502 /404.html;
    include /etc/nginx/default.d/*.conf;
    #location ~* .flv$ {
    location ~\.flv {
    flv;
    }
   #此处是文件的地址,
    ssl_certificate /etc/nginx/ssl/www.yourname.com-ca-bundle.crt;
    ssl_certificate_key /etc/nginx/ssl/www.yourname.com.key;
    }
 

多域名同样可以

你可能感兴趣的:(nginx 配置https和http跳转https)