admin 发表于 2014-5-25 16:51:36

Nginx配置SSL并强制http跳转到https

这个还不错先学习了。今天要设置下ssl。server {
    listen       80;
    server_name ssl.zhujitou.com;
    rewrite ^/(.*) https://ssl.zhujitou.com/$1 permanent; #关键代码
}
server
{
    listen 443;
    server_name ssl.zhujitou.com; #server_name end
    index index.html index.htm index.php; #index end

    set $subdomain '';
    root  /home/wwwroot/ssl.zhujitou.com/web$subdomain;
    include rewrite/typecho.conf; #rewrite end

    #error_page
        error_page 403 /ErrorPages/403.html;
        error_page 404 /ErrorPages/404.html;
        location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$
    {
                root /home/wwwroot/ssl.zhujitou.com/web;
        }


    location ~ .*\.php$
    {
        fastcgi_pass  unix:/tmp/php-cgi-ssl.lanbing.org.sock;
        fastcgi_index index.php;
        include fcgi-host.conf;
        fastcgi_param DOCUMENT_ROOT  /web$subdomain;
        fastcgi_param SCRIPT_FILENAME  /web$subdomain$fastcgi_script_name;
       }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
    {
        expires      30d;
    }

    location ~ .*\.(js|css)$
    {
        expires      12h;
    }

    access_log off; #access_log end
    error_log /dev/null; #error_log end
    ssl on; #关键代码
    ssl_certificate /usr/local/nginx/conf/ssl/ssl.zhujitou.com.crt;  #关键代码
    ssl_certificate_key /usr/local/nginx/conf/ssl/ssl.zhujitou.com.pem; #关键代码
}
页: [1]
查看完整版本: Nginx配置SSL并强制http跳转到https