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

linux cooljun 132℃ 0评论

配置信息如下

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; #关键代码
}

转载请注明:cooljun小站 » Nginx配置SSL并强制http跳转到https

如果你觉得这篇文章对你有帮助,请支持我继续更新网站 !捐赠本站
喜欢 (0)or分享 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址