主机头
标题:
Nginx配置SSL并强制http跳转到https
[打印本页]
作者:
admin
时间:
2014-5-25 16:51
标题:
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; #关键代码
}
复制代码
欢迎光临 主机头 (http://zhujitou.com/)
Powered by Discuz! X2.5