add seo
This commit is contained in:
141
server/nginx-www.tianyuandb.com.conf
Normal file
141
server/nginx-www.tianyuandb.com.conf
Normal file
@@ -0,0 +1,141 @@
|
||||
# 天远数据 - www.tianyuandb.com 完整配置(含 SEO 爬虫检测)
|
||||
# 使用前请将 public/seo-templates 上传到服务器:/www/sites/www.tianyuandb.com/index/seo-templates/
|
||||
# 生成 tianyuandb 用模板:SEO_BASE_URL=https://www.tianyuandb.com node generate-seo-templates.cjs
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen 443 ssl http2;
|
||||
server_name www.tianyuandb.com tianyuandb.com;
|
||||
index index.php index.html index.htm default.php default.htm default.html;
|
||||
root /www/sites/www.tianyuandb.com/index;
|
||||
|
||||
# ========== 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 = '/historyQuery') { set $seo_file historyQuery.html; }
|
||||
if ($uri = '/agent') { set $seo_file agent.html; }
|
||||
if ($uri = '/agent/promote') { set $seo_file agent-promote.html; }
|
||||
if ($uri = '/agent/invitation') { set $seo_file agent-invitation.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 配置结束 ==========
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
|
||||
access_log /www/sites/www.tianyuandb.com/log/access.log main;
|
||||
error_log /www/sites/www.tianyuandb.com/log/error.log;
|
||||
|
||||
location ^~ /.well-known/acme-challenge {
|
||||
allow all;
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
# SEO:爬虫访问时返回静态 HTML 模板
|
||||
location /seo-templates/ {
|
||||
internal;
|
||||
add_header Content-Type "text/html; charset=utf-8";
|
||||
add_header X-SEOMiddleware "nginx-prerendered";
|
||||
}
|
||||
|
||||
location / {
|
||||
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:21004;
|
||||
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";
|
||||
}
|
||||
|
||||
location ^~ /api/v1/chat {
|
||||
resolver 8.8.8.8 114.114.114.114 valid=10s;
|
||||
resolver_timeout 5s;
|
||||
set $backend "chat.guimiaokeji.com";
|
||||
rewrite ^/api/v1/(.*)$ /$1 break;
|
||||
proxy_pass https://$backend;
|
||||
proxy_set_header Host $backend;
|
||||
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;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_http_version 1.1;
|
||||
add_header X-Cache $upstream_cache_status;
|
||||
add_header Cache-Control no-cache;
|
||||
proxy_ssl_server_name off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
include /www/sites/www.tianyuandb.com/redirect/*.conf;
|
||||
|
||||
if ($scheme = http) {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
ssl_certificate /www/sites/www.tianyuandb.com/ssl/fullchain.pem;
|
||||
ssl_certificate_key /www/sites/www.tianyuandb.com/ssl/privkey.pem;
|
||||
ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1;
|
||||
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK:!KRB5:!SRP:!CAMELLIA:!SEED;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
error_page 497 https://$host$request_uri;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
Reference in New Issue
Block a user