Files
xfc_webview_V2/server/nginx-www.xingfucha.cn.conf

149 lines
5.5 KiB
Plaintext
Raw Normal View History

2026-02-28 15:43:14 +08:00
# 在原有配置基础上增加 SEO 爬虫检测,其余保持不变
# 部署时请将 public/seo-templates 整个目录上传到服务器:/www/wwwroot/www.xingfucha.cn/seo-templates
server
{
listen 80;
listen 443 ssl;
listen 443 quic;
listen [::]:443 ssl;
listen [::]:443 quic;
http2 on;
listen [::]:80;
server_name xingfucha.cn www.xingfucha.cn p.xingfucha.cn;
index index.html index.htm default.htm default.html;
root /www/wwwroot/www.xingfucha.cn;
# ========== SEO 爬虫检测与模板映射(请勿删除) ==========
set $is_crawler 0;
if ($http_user_agent ~* "baiduspider|baiduspider-mobile|baiduspider-image|baiduspider-video|baiduspider-news|baiduboxapp") {
set $is_crawler 1;
}
if ($http_user_agent ~* "googlebot|googlebot-image|googlebot-news|googlebot-mobile|googlebot-video|google-web-snippet") {
set $is_crawler 1;
}
if ($http_user_agent ~* "bingbot|msnbot") {
set $is_crawler 1;
}
if ($http_user_agent ~* "360spider|soha-agent|haosouspider") {
set $is_crawler 1;
}
if ($http_user_agent ~* "sogou spider|sogou news spider|sogou orion spider|sogou-blog") {
set $is_crawler 1;
}
if ($http_user_agent ~* "slurp|sosospider|sosoimagespider|youdaobot|yodaobot") {
set $is_crawler 1;
}
if ($http_user_agent ~* "bytedance-spider|toutiaospider") {
set $is_crawler 1;
}
if ($http_user_agent ~* "facebookexternalhit|facebookcatalog|twitterbot|linkedinbot|whatsapp|telegrambot|viber|line") {
set $is_crawler 1;
}
set $seo_file index.html;
if ($uri = '/') { set $seo_file index.html; }
if ($uri = '/agent') { set $seo_file agent.html; }
if ($uri = '/help') { set $seo_file help.html; }
if ($uri = '/help/guide') { set $seo_file help-guide.html; }
if ($uri = '/example') { set $seo_file example.html; }
if ($uri = '/service') { set $seo_file service.html; }
if ($uri = '/inquire/personalData') { set $seo_file inquire-personalData.html; }
if ($uri = '/inquire/companyinfo') { set $seo_file inquire-companyinfo.html; }
if ($uri = '/inquire/preloanbackgroundcheck') { set $seo_file inquire-preloanbackgroundcheck.html; }
if ($uri = '/inquire/marriage') { set $seo_file inquire-marriage.html; }
if ($uri = '/inquire/backgroundcheck') { set $seo_file inquire-backgroundcheck.html; }
if ($uri = '/inquire/homeservice') { set $seo_file inquire-homeservice.html; }
# ========== SEO 配置结束 ==========
#CERT-APPLY-CHECK--START
include /www/server/panel/vhost/nginx/well-known/www.xingfucha.cn.conf;
#CERT-APPLY-CHECK--END
#SSL-START
#error_page 404/404.html;
ssl_certificate /www/server/panel/vhost/cert/www.xingfucha.cn/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/www.xingfucha.cn/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_tickets on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
add_header Alt-Svc 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"';
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#REWRITE-START
include /www/server/panel/vhost/rewrite/html_www.xingfucha.cn.conf;
#REWRITE-END
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location ~ \.well-known{
allow all;
}
if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) {
return 403;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
# SEO爬虫访问时走 /seo-templates/ 内部路径,用 root 找文件(避免 alias 兼容问题)
location /seo-templates/ {
internal;
add_header Content-Type "text/html; charset=utf-8";
add_header X-SEOMiddleware "nginx-prerendered";
}
location / {
# 爬虫则返回对应 SEO 模板root 已是 /www/wwwroot/www.xingfucha.cn故文件为 .../seo-templates/index.html
if ($is_crawler = 1) {
rewrite ^ /seo-templates/$seo_file break;
}
try_files $uri $uri/ /index.html;
}
location /api/v1 {
proxy_pass http://127.0.0.1:23204;
proxy_set_header Host 127.0.0.1:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
add_header X-Cache $upstream_cache_status;
proxy_set_header X-Host $host:$server_port;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 30s;
proxy_read_timeout 86400s;
proxy_send_timeout 30s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
access_log /www/wwwlogs/www.xingfucha.cn.log;
error_log /www/wwwlogs/www.xingfucha.cn.error.log;
}