配置信息如下
server {
listen 80;
server_name ssl.lanbing.org;
rewrite ^/(.*) https://ssl.lanbing.org/$1 permanent; #关键代码
}
server
{
listen 443;
server_name ssl.lanbing.org; #server_name end
index index.html index.htm index.php; #index end
set $subdomain '';
root /home/wwwroot/ssl.lanbing.org/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.lanbing.org/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.lanbing.org.crt; #关键代码
ssl_certificate_key /usr/local/nginx/conf/ssl/ssl.lanbing.org.pem; #关键代码
}