9-15 2,437 views
本博客的nginx 配置文件
server {
listen 80;#80和443端口同时监听
listen 443 ssl;
server_name www.koukousky.com koukousky.com;
index index.html index.htm index.php;
root /apps/koukousky;
#ssl on;
ssl_certificate /etc/ssl/koukousky.com.pem;
ssl_certificate_key /etc/ssl/koukousky/koukousky.com.key;
ssl_session_timeout 5m;
#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !kECDH !DSS !MD5 !RC4 !EXP !PSK !SRP !CAMELLIA !SEED !3DES';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
//不是www过来的跳转到带www的域名
if ($http_host !~ "^www.koukousky.com$") {
rewrite ^(.*) http://www.koukousky.com$1 permanent;
}
//防盗链图片
location ~* \.(gif|jpg|png|bmp|zip|pdf)$ {
valid_referers none blocked *.koukousky.com;
if ($invalid_referer) {
return 403;
}
}
//缓存图片
location ~ .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg)$
{
expires 7d;
}
//缓存js css
location ~ .*\.(?:js|css)$
{
expires 7d;
}
}
//隐藏index.php
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
index index.php;
}
//解析php
location ~ \.php {
//如果是进程文件请换成 fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 300;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
}
}