Nginx ssl的配置和Nginx 301重定向的配置

  • A+
所属分类:Nginx

Nginx想必大家都懂的,灰常强大,301重定向也不必多说,转移权重的。SSL对于个人站来说可有可无,但是对于服务于大众的企业站来说,这是个必不可少的安全传输。
废话不多说了,直接上CONF CODE

Nginx ssl配置


server
{
listen 80;
server_name sishaofeng.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443;
server_name sishaofeng.com;
root /home/wwwroot/sishaofeng.com;
ssl on;
ssl_certificate /root/certs/ssl.crt;
ssl_certificate_key /root/certs/ssl.key;
ssl_session_timeout 5m;

ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
include other.conf;
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param HTTPS on;
}

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

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

log_format sishaofeng.com '$remote_addr - $remote_user [$time_local] $request '
'$status $body_bytes_sent $http_referer '
'$http_user_agent $http_x_forwarded_for';
access_log /home/wwwlogs/sishaofeng.com.log access;
}

Nginx 301重定向


server
{
listen 80;
server_name sishaofeng.com;
rewrite ^/(.*)$ https://www.sishaofeng.com/$1 permanent;
access_log off;
}

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: