upstream backend {
    server andys-dandy-site-4c8fd6.webflow.io:443;
}

server
{
    listen 80;
    listen 443 ssl http2 ;
    server_name pog.cxhy.cn;
    index index.php index.html index.htm default.php default.htm default.html;
    root /data/www/pog.cxhy.cn;
    #CERT-APPLY-CHECK--START
    # 用于SSL证书申请时的文件验证相关配置 -- 请勿删除
    include /www/server/panel/vhost/nginx/well-known/pog.cxhy.cn.conf;
    #CERT-APPLY-CHECK--END

    #SSL-START SSL相关配置，请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate    /www/server/panel/vhost/cert/pog.cxhy.cn/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/pog.cxhy.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_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    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
 
  location / {
        proxy_pass https://backend;
     
        
        proxy_set_header Host  andys-dandy-site-4c8fd6.webflow.io;
        
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Port $server_port;
        
        # 处理重定向，确保重定向后的URL仍然指向pog.lcxhy.cn
        proxy_redirect off;
        
        # 添加更多代理头，模拟真实浏览器
        proxy_set_header User-Agent $http_user_agent;
        proxy_set_header Accept $http_accept;
        proxy_set_header Accept-Language $http_accept_language;
        proxy_set_header Accept-Encoding $http_accept_encoding;
        proxy_set_header Connection "";
        
        # 内容替换 - 处理绝对路径和域名引用
        sub_filter 'https://andys-dandy-site-4c8fd6.webflow.io' 'https://pog.lcxhy.cn';
        sub_filter 'http://andys-dandy-site-4c8fd6.webflow.io' 'https://pog.lcxhy.cn';
        sub_filter '//andys-dandy-site-4c8fd6.webflow.io' '//pog.lcxhy.cn';
        sub_filter 'andys-dandy-site-4c8fd6.webflow.io' 'pog.lcxhy.cn';
        sub_filter_once off;
        sub_filter_types text/html text/css text/javascript application/javascript;
        
        # 处理JavaScript域名检测 - 注入修复脚本
        sub_filter '</head>' '<script>
            // 修复域名检测
            Object.defineProperty(window.location, "hostname", {
                get: function() { return "andys-dandy-site-4c8fd6.webflow.io"; }
            });
            Object.defineProperty(window.location, "host", {
                get: function() { return "andys-dandy-site-4c8fd6.webflow.io"; }
            });
            Object.defineProperty(window.location, "origin", {
                get: function() { return "https://andys-dandy-site-4c8fd6.webflow.io"; }
            });
            // 修复document.domain
            Object.defineProperty(document, "domain", {
                get: function() { return "andys-dandy-site-4c8fd6.webflow.io"; },
                set: function() { return "andys-dandy-site-4c8fd6.webflow.io"; }
            });
        </script></head>';
        
        # 可选：添加缓存控制
        proxy_cache_valid 200 1h;
        proxy_cache_valid 404 1m;
        
        # 处理超时
        proxy_connect_timeout 30s;
        proxy_send_timeout 30s;
        proxy_read_timeout 30s;
    }
   

    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }

  
    access_log  /www/wwwlogs/pog.cxhy.cn.log;
    error_log  /www/wwwlogs/pog.cxhy.cn.error.log;
}