# g2.tkmind.cn → 301 跳转到 m.tkmind.cn（保留微信 webhook 直至后台改完服务器 URL）
# 安装：/etc/nginx/conf.d/g2.tkmind.cn.conf

server {
    listen 80;
    listen [::]:80;
    server_name g2.tkmind.cn;
    location /.well-known/acme-challenge/ { root /var/www/certbot; }
    location / { return 301 https://$host$request_uri; }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name g2.tkmind.cn;

    ssl_certificate     /etc/letsencrypt/live/g2.tkmind.cn/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/g2.tkmind.cn/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location = /webhooks/wechat-mp/messages {
        proxy_pass http://127.0.0.1:19081;
        proxy_http_version 1.1;
        proxy_set_header Host g2.tkmind.cn;
        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_read_timeout 60;
        proxy_send_timeout 60;
        add_header Alt-Svc "" always;
        proxy_buffering off;
    }

    location / {
        return 301 https://m.tkmind.cn$request_uri;
    }
}
