map $http_upgrade $connection_upgrade {
    default upgrade;
    'websocket' upgrade;
}

server {
    listen 80;
    listen 443 ssl;
    server_name v3.adwebcloud.com zhigeng.adwebcloud.com;

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

    ssl_certificate /root/.acme.sh/v3.adwebcloud.com_ecc/fullchain.cer;
    ssl_certificate_key /root/.acme.sh/v3.adwebcloud.com_ecc/v3.adwebcloud.com.key;

    include /etc/nginx/conf.d/adweb3/*.conf;

    index index.html;
    root /home/ubuntu/adweb3-web/dist; # 这里改成前端静态
    location / {
        try_files $uri $uri/ /index.html;

        # 后端 API 的转发
        location /adweb3/ {
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_pass http://127.0.0.1:8080;
        }

        location /adweb3/websocket/ {
            proxy_pass http://127.0.0.1:8080/adweb3/websocket/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header X-real-ip $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
    }
}

server {
    listen 80;
    server_name xxl-job.v3.adwebcloud.com;

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

    location / {
        # 后端 API 的转发
        location / {
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_pass http://127.0.0.1:8090;
        }
    }
}
