nginx配置参考(包含https重定向到http)

本站的服务器原本是win2008+iis,因为需要ssl更换为ubuntu+nginx

nginx配置过程中,遇到许多难度。

本人采用的配置方式是一个域名(二级域名),一个配置文件,通过include的方式

配置文件实例

server {
listen       80;
server_name  blog.imcyk.com;
rewrite ^ https://$http_host$request_uri? permanent;
}
server {
listen 443;
server_name blog.imcyk.com;
ssl on;
ssl_certificate conf.d/blog_imcyk_com/blog_imcyk_com.pem;
ssl_certificate_key conf.d/blog_imcyk_com/blog_imcyk_com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
location / {  
index index.html index.php;  
root /var/www/blog;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ \.php$ {  
root           /var/www/blog; 
fastcgi_split_path_info ^(.+\.php)(/.+)$; 
fastcgi_pass unix:/var/run/php5-fpm.sock;  
fastcgi_index  index.php;  
fastcgi_param  SCRIPT_FILENAME  html$fastcgi_script_name;  
include        fastcgi_params;  
}    
}


原文链接:,转发请注明来源!
「nginx配置参考(包含https重定向到http)」评论列表

发表评论