File size: 2,045 Bytes
36fc1ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
set -e

if [ -z "$UUID" ]; then
  echo "❌ UUID را در Variables تعریف کنید!"
  exit 1
fi

WSPATH=${WSPATH:-/api/v1/aichatbot}

cat > /etc/xray/config.json << EOF
{
  "log": {"loglevel": "warning"},
  "inbounds": [{
    "port": 9000,
    "listen": "127.0.0.1",
    "protocol": "vless",
    "settings": {
      "clients": [{"id": "${UUID}"}],   # flow رو حذف کن
      "decryption": "none"
    },
    "streamSettings": {
      "network": "ws",
      "wsSettings": {"path": "${WSPATH}"}
    }
  }],
  "outbounds": [{"protocol": "freedom"}]
}
EOF

echo "✅ دمو AI راه‌اندازی شد | Path: ${WSPATH}"

cat > /tmp/nginx.conf << EOF
pid /tmp/nginx.pid;

events { worker_connections 1024; }

http {
    client_body_temp_path /tmp/nginx/client_body 1 2;
    proxy_temp_path       /tmp/nginx/proxy;
    fastcgi_temp_path     /tmp/nginx/fastcgi;
    uwsgi_temp_path       /tmp/nginx/uwsgi;
    scgi_temp_path        /tmp/nginx/scgi;

    server {
        listen 7860 default_server;
        server_name _;

        access_log /var/log/nginx/access.log;
        error_log  /var/log/nginx/error.log warn;

        location / {
            root /www;
            index index.html;
            try_files \$uri \$uri/ =404;
        }

        location ${WSPATH} {
            proxy_pass http://127.0.0.1:9000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade \$http_upgrade;
            proxy_set_header Connection "upgrade";
            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 X-Forwarded-Proto \$scheme;
            proxy_set_header Origin "https://chat.openai.com";  # برای obfuscation اضافی
            proxy_read_timeout 86400;
        }
    }
}
EOF

echo "nginx.conf ساخته شد با WSPATH: ${WSPATH}"
grep "location" /tmp/nginx.conf

ai-core run -config /etc/xray/config.json &

exec nginx -c /tmp/nginx.conf -g "daemon off;"