map $http_upgrade $connection_upgrade {
     default upgrade;
     'websocket'      upgrade;
}
server {
#     listen  443 ssl;
    listen 8080;
#     server_name  www.chatgpt.com; #替换成你自己的域名

#     ssl_certificate     xxx.pem;  # 替换成自己的 SSL 证书
#     ssl_certificate_key  xxx.key;
#     ssl_session_timeout  5m;
#     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#     ssl_prefer_server_ciphers on;

    # 日志地址
    access_log  /var/log/access.log;
    error_log /var/log/error.log;

    index index.html;
    root /var/www/app/dist; # 这里改成前端静态页面的地址

    location / {
        try_files $uri $uri/ /index.html;

        # 后端 API 的转发
        location /api/ {
                proxy_http_version 1.1;
                proxy_connect_timeout 300s;
                proxy_read_timeout 300s;
                proxy_send_timeout 12s;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
                proxy_pass http://172.28.173.76:6789; # 这里改成后端服务的内网 IP 地址
        }

        # 静态资源转发
        location /static/ {
            proxy_pass http://172.28.173.76:6789; # 这里改成后端服务的内网 IP 地址
        }
    }
}