Nginx 常规配置

2020-09-02 78

# 页面的常规设置
# 页面的常规设置
server {
listen 80;
server_name 52open.cn www.52open.cn;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name 52open.cn www.52open.cn;
root /var/www/emlog6.0;
index index.php index.html;
charset utf-8;
ssl on; # 启用ssl功能
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
# 伪静态的配置
location / {
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/(post|record|sort|author|page)-([0-9]+)\.html$ /index.php?$1=$2;
rewrite ^/(post|record|sort|author|page)/([0-9]+)$ /index.php?$1=$2;
}
rewrite ^/tag-(.+)\.html$ /index.php?tag=$1;
rewrite ^/tag/(.+)$ /index.php?tag=$1;
rewrite ^/t/page/([0-9]+)$ /t/index.php?page=$1;
}
# php 语言支持配置
location ~ \.php {
root /var/www/emlog6.0;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 错误页面跳转配置
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}