Files changed (10) hide show
  1. .gitkeep +0 -0
  2. Dockerfile +15 -26
  3. README.md +3 -2
  4. start.sh +4 -40
  5. sync.sh +0 -73
  6. warp_proxy.sh +0 -58
  7. x-ui-configs/config.json +0 -135
  8. x-ui-configs/x-ui.db +0 -0
  9. x-ui-deployment-scheme.md +49 -0
  10. x-ui.key +1 -0
.gitkeep DELETED
File without changes
Dockerfile CHANGED
@@ -1,34 +1,26 @@
1
  FROM debian:bullseye-slim
2
 
3
- # Install prerequisites
4
  RUN apt-get update && apt-get install -y \
5
- curl \
6
- gnupg \
7
- ca-certificates \
8
  dos2unix \
9
  wget \
 
10
  tar \
11
  bash \
 
12
  --no-install-recommends && \
13
  rm -rf /var/lib/apt/lists/*
14
 
15
  SHELL ["/bin/bash", "-c"]
16
 
17
- # Set a working directory
18
- WORKDIR /opt/app
19
-
20
- # Install tools
21
- ARG SINGBOX_VERSION=1.12.8
22
- RUN wget -O /tmp/sing-box.tar.gz "https://github.com/SagerNet/sing-box/releases/download/v${SINGBOX_VERSION}/sing-box-${SINGBOX_VERSION}-linux-amd64.tar.gz" && \
23
- tar -zxvf /tmp/sing-box.tar.gz -C /tmp && \
24
- mv /tmp/sing-box-${SINGBOX_VERSION}-linux-amd64/sing-box /usr/local/bin/sing-box && \
25
- chmod +x /usr/local/bin/sing-box && \
26
- rm -rf /tmp/sing-box*
27
  ARG CHISEL_VERSION=1.10.1
28
  RUN wget https://github.com/jpillora/chisel/releases/download/v${CHISEL_VERSION}/chisel_${CHISEL_VERSION}_linux_amd64.gz -O /tmp/chisel.gz && \
29
  gunzip /tmp/chisel.gz && \
30
  mv /tmp/chisel /usr/local/bin/chisel && \
31
  chmod +x /usr/local/bin/chisel
 
 
32
  RUN ARCH=$(uname -m) && \
33
  if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi && \
34
  if [ "$ARCH" = "aarch64" ]; then ARCH="arm64"; fi && \
@@ -38,22 +30,19 @@ RUN ARCH=$(uname -m) && \
38
  tar -zxvf /usr/local/x-ui-linux-*.tar.gz -C /usr/local/x-ui/ --strip-components=1 && \
39
  rm /usr/local/x-ui-linux-*.tar.gz && \
40
  chmod +x /usr/local/x-ui/x-ui && \
41
- cp /usr/local/x-ui/x-ui.sh /usr/bin/x-ui && \
42
-
43
- # --- Backup original bin contents ---
44
- mkdir -p /opt/xray-backup && \
45
- cp -r /usr/local/x-ui/bin/. /opt/xray-backup/
46
 
47
- # Copy all files from the build context (huggingface-x-ui-final) into the work directory
48
- COPY . .
49
 
50
- # Make scripts executable
51
- RUN chmod +x /opt/app/warp_proxy.sh && \
52
- chmod +x /opt/app/start.sh
53
 
54
  # Expose the x-ui port
55
- EXPOSE 2023
56
 
57
  # Set the entrypoint to our startup script
58
  RUN chmod -R 777 /usr/local/x-ui/
59
- ENTRYPOINT ["/bin/bash", "-c", "/opt/app/start.sh"]
 
 
 
1
  FROM debian:bullseye-slim
2
 
3
+ # Install necessary packages and clean up
4
  RUN apt-get update && apt-get install -y \
 
 
 
5
  dos2unix \
6
  wget \
7
+ curl \
8
  tar \
9
  bash \
10
+ ca-certificates \
11
  --no-install-recommends && \
12
  rm -rf /var/lib/apt/lists/*
13
 
14
  SHELL ["/bin/bash", "-c"]
15
 
16
+ # Install chisel
 
 
 
 
 
 
 
 
 
17
  ARG CHISEL_VERSION=1.10.1
18
  RUN wget https://github.com/jpillora/chisel/releases/download/v${CHISEL_VERSION}/chisel_${CHISEL_VERSION}_linux_amd64.gz -O /tmp/chisel.gz && \
19
  gunzip /tmp/chisel.gz && \
20
  mv /tmp/chisel /usr/local/bin/chisel && \
21
  chmod +x /usr/local/bin/chisel
22
+
23
+ # Download and extract 3x-ui
24
  RUN ARCH=$(uname -m) && \
25
  if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi && \
26
  if [ "$ARCH" = "aarch64" ]; then ARCH="arm64"; fi && \
 
30
  tar -zxvf /usr/local/x-ui-linux-*.tar.gz -C /usr/local/x-ui/ --strip-components=1 && \
31
  rm /usr/local/x-ui-linux-*.tar.gz && \
32
  chmod +x /usr/local/x-ui/x-ui && \
33
+ cp /usr/local/x-ui/x-ui.sh /usr/bin/x-ui
 
 
 
 
34
 
35
+ # Copy the startup script
36
+ COPY start.sh /usr/local/bin/start.sh
37
 
38
+ # Make the script executable
39
+ RUN chmod +x /usr/local/bin/start.sh
 
40
 
41
  # Expose the x-ui port
42
+ EXPOSE 62789
43
 
44
  # Set the entrypoint to our startup script
45
  RUN chmod -R 777 /usr/local/x-ui/
46
+ ENTRYPOINT ["/bin/bash", "-c", "/usr/local/bin/start.sh"]
47
+ # Trivial change to force rebuild
48
+
README.md CHANGED
@@ -1,11 +1,12 @@
1
  ---
2
  license: mit
3
- title: X-UI with Chisel and WARP
4
  sdk: docker
5
  emoji: 🚀
6
  colorFrom: gray
7
  colorTo: indigo
8
  pinned: true
9
- app_port: 2023
10
  persistent_storage: true
11
  ---
 
 
1
  ---
2
  license: mit
3
+ title: x-ui
4
  sdk: docker
5
  emoji: 🚀
6
  colorFrom: gray
7
  colorTo: indigo
8
  pinned: true
9
+ app_port: 2053
10
  persistent_storage: true
11
  ---
12
+ --- title: X-UI Proxy emoji: 🚀 colorFrom: blue colorTo: indigo sdk: docker app_port: 2053 sdk_version: "1.0" pinned: false ---\n\n# X-UI Proxy Hugging Face Space\n\nThis Space hosts a Dockerized X-UI instance, accessible via a Chisel tunnel.
start.sh CHANGED
@@ -1,30 +1,4 @@
1
  #!/bin/bash
2
- # Restore original xray binaries and data files from the backup location
3
- # to the tmpfs-mounted bin directory.
4
- cp -r /opt/xray-backup/. /usr/local/x-ui/bin/
5
- echo "Architecture: $(uname -m)"
6
-
7
- # --- Restore Configs from baked-in repo files ---
8
- CONFIG_DIR_IN_REPO="/opt/app/x-ui-configs"
9
- LIVE_XUI_DB_PATH="/tmp/x-ui.db"
10
- LIVE_XRAY_CONFIG_PATH="/usr/local/x-ui/bin/config.json"
11
-
12
- echo "Restoring configs from baked-in files..."
13
- if [ -f "${CONFIG_DIR_IN_REPO}/config.json" ]; then
14
- cp -f "${CONFIG_DIR_IN_REPO}/config.json" "${LIVE_XRAY_CONFIG_PATH}"
15
- echo "Restored config.json"
16
- fi
17
- if [ -f "${CONFIG_DIR_IN_REPO}/x-ui.db" ]; then
18
- cp -f "${CONFIG_DIR_IN_REPO}/x-ui.db" "${LIVE_XUI_DB_PATH}"
19
- echo "Restored x-ui.db"
20
- fi
21
- # --- End Restore ---
22
-
23
- # --- WARP SOCKS Proxy Setup ---
24
- echo "Starting WARP SOCKS5 proxy via sing-box..."
25
- nohup /opt/app/warp_proxy.sh > /tmp/warp.log 2>&1 &
26
- echo "WARP SOCKS5 proxy started in background. Log at /tmp/warp.log"
27
- # --- End WARP SOCKS Proxy Setup ---
28
 
29
  # Set a writable directory for the x-ui database
30
  export XUI_DB_FOLDER=/tmp
@@ -33,8 +7,7 @@ export XUI_DB_FOLDER=/tmp
33
  run_chisel() {
34
  while true; do
35
  echo "Starting chisel client..."
36
- # This is the line from the user's last instruction
37
- /usr/local/bin/chisel client -v --auth "cloud:2025" --keepalive 25s "https://vds1.iri1968.dpdns.org/chisel-ws" R:8080:127.0.0.1:2023 R:8081:127.0.0.1:20001
38
  echo "Chisel client exited. Restarting in 5 seconds..."
39
  sleep 5
40
  done
@@ -43,21 +16,12 @@ run_chisel() {
43
  # Start chisel in the background
44
  run_chisel &
45
 
46
- # Wait a moment for the background process to start
47
- sleep 2
48
-
49
- # --- ADDED USER SETTINGS ---
50
- echo "Configuring x-ui web base path..."
51
  /usr/local/x-ui/x-ui setting -webBasePath /
52
 
53
- echo "Resetting x-ui admin credentials..."
54
  /usr/local/x-ui/x-ui setting -username prog10 -password 04091968
55
 
56
- # This command is from a previous step, it is needed for the port
57
- /usr/local/x-ui/x-ui setting -port 2023
58
- # --- END ADDED SETTINGS ---
59
-
60
  # Start x-ui in the foreground
61
- echo "Starting x-ui panel..."
62
  cd /usr/local/x-ui
63
- exec ./x-ui
 
1
  #!/bin/bash
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  # Set a writable directory for the x-ui database
4
  export XUI_DB_FOLDER=/tmp
 
7
  run_chisel() {
8
  while true; do
9
  echo "Starting chisel client..."
10
+ /usr/local/bin/chisel client -v --auth "cloud:2025" vds1.iri1968.dpdns.org:8443 R:8000:127.0.0.1:2053
 
11
  echo "Chisel client exited. Restarting in 5 seconds..."
12
  sleep 5
13
  done
 
16
  # Start chisel in the background
17
  run_chisel &
18
 
19
+ # Set webBasePath
 
 
 
 
20
  /usr/local/x-ui/x-ui setting -webBasePath /
21
 
22
+ # Reset x-ui admin credentials to admin/admin
23
  /usr/local/x-ui/x-ui setting -username prog10 -password 04091968
24
 
 
 
 
 
25
  # Start x-ui in the foreground
 
26
  cd /usr/local/x-ui
27
+ ./x-ui
sync.sh DELETED
@@ -1,73 +0,0 @@
1
- #!/bin/bash
2
-
3
- # This script assumes that start.sh has already cloned the repo and set up SSH.
4
-
5
- # --- Paths ---
6
- # The git repo is cloned into /tmp/repo by start.sh
7
- GIT_REPO_DIR="/tmp/repo"
8
- LOG_FILE="/tmp/sync.log"
9
-
10
- # Live files to be backed up
11
- XUI_DB_PATH="/tmp/x-ui.db"
12
- XRAY_CONFIG_PATH="/usr/local/x-ui/bin/config.json"
13
-
14
- # Destination for the backed up files inside the git repo
15
- TARGET_DIR="${GIT_REPO_DIR}/x-ui-configs"
16
-
17
- # Git commit message
18
- COMMIT_MESSAGE="Automatic sync of x-ui configs"
19
-
20
- # --- Functions ---
21
-
22
- log() {
23
- echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
24
- }
25
-
26
- # --- Main ---
27
-
28
- log "--- Starting Hourly Sync ---"
29
-
30
- # Navigate to the Git repository
31
- if [ ! -d "$GIT_REPO_DIR/.git" ]; then
32
- log "Error: Git repository not found at $GIT_REPO_DIR. Exiting sync."
33
- exit 1
34
- fi
35
- cd "$GIT_REPO_DIR" || exit 1
36
-
37
- # Configure git user for this operation
38
- git config user.email "igor04091968@gmail.com"
39
- git config user.name "igor04091968"
40
-
41
- # Pull latest changes first to avoid conflicts
42
- log "Pulling latest changes from remote..."
43
- git pull --rebase
44
-
45
- # Ensure the target directory for configs exists
46
- mkdir -p "$TARGET_DIR"
47
-
48
- # Copy live files into the git repo
49
- log "Copying live db from ${XUI_DB_PATH} and config from ${XRAY_CONFIG_PATH} into git repo..."
50
- cp -f "${XUI_DB_PATH}" "${TARGET_DIR}/x-ui.db"
51
- cp -f "${XRAY_CONFIG_PATH}" "${TARGET_DIR}/config.json"
52
-
53
- # Add, commit, and push
54
- log "Adding changes to git..."
55
- git add "$TARGET_DIR/x-ui.db" "$TARGET_DIR/config.json"
56
-
57
- # Commit only if there are changes
58
- if ! git diff-index --quiet HEAD; then
59
- log "Found changes, committing..."
60
- git commit -m "$COMMIT_MESSAGE"
61
- log "Committed changes."
62
-
63
- log "Pushing changes to remote..."
64
- if git push; then
65
- log "Successfully pushed changes to the remote repository."
66
- else
67
- log "Error: Failed to push changes."
68
- fi
69
- else
70
- log "No changes to commit."
71
- fi
72
-
73
- log "--- Hourly Sync Finished ---"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
warp_proxy.sh DELETED
@@ -1,58 +0,0 @@
1
- #!/bin/bash
2
- # Based on the entrypoint from Mon-ius/Docker-Warp-Socks v5
3
-
4
- set -e
5
- sleep 3
6
-
7
- # Get WARP configuration
8
- RESPONSE=$(curl -fsSL bit.ly/create-cloudflare-warp | sh -s)
9
-
10
- # Extract variables
11
- CF_CLIENT_ID=$(echo "$RESPONSE" | grep -oP '(?<=CLIENT_ID = ).*$')
12
- CF_PRIVATE_KEY=$(echo "$RESPONSE" | grep -oP '(?<=PRIVATE_KEY = ).*$')
13
- CF_ADDR_V4=$(echo "$RESPONSE" | grep -oP '(?<=V4 = ).*$')
14
- CF_ADDR_V6=$(echo "$RESPONSE" | grep -oP '(?<=V6 = ).*$')
15
-
16
- # Generate sing-box config
17
- cat > /tmp/sing-box-config.json <<EOF
18
- {
19
- "log": {
20
- "level": "info",
21
- "timestamp": true
22
- },
23
- "inbounds": [
24
- {
25
- "type": "socks",
26
- "tag": "socks-in",
27
- "listen": "0.0.0.0",
28
- "listen_port": 1080
29
- }
30
- ],
31
- "outbounds": [
32
- {
33
- "type": "wireguard",
34
- "tag": "warp-out",
35
- "server": "engage.cloudflareclient.com",
36
- "server_port": 2408,
37
- "local_address": [
38
- "${CF_ADDR_V4}/32",
39
- "${CF_ADDR_V6}/128"
40
- ],
41
- "private_key": "${CF_PRIVATE_KEY}",
42
- "peer_public_key": "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
43
- "reserved": [${reserved_bytes}],
44
- "mtu": 1280
45
- }
46
- ]
47
- }
48
- EOF
49
-
50
- # Replace reserved_bytes placeholder
51
- # od -An -t u1 formats the bytes as unsigned decimal integers
52
- reserved_bytes=$(echo "$CF_CLIENT_ID" | base64 -d | od -An -t u1 | awk
53
- '{print $1", "$2", "$3}')
54
- sed -i "s/\[${reserved_bytes}\]/\[${reserved_bytes}\]/" /tmp/sing-box-config.json
55
-
56
-
57
- echo "Starting sing-box WARP proxy..."
58
- exec /usr/local/bin/sing-box run -c /tmp/sing-box-config.json
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
x-ui-configs/config.json DELETED
@@ -1,135 +0,0 @@
1
- {
2
- "log": {
3
- "access": "none",
4
- "dnsLog": false,
5
- "error": "",
6
- "loglevel": "warning",
7
- "maskAddress": ""
8
- },
9
- "routing": {
10
- "domainStrategy": "AsIs",
11
- "rules": [
12
- {
13
- "type": "field",
14
- "inboundTag": [
15
- "api"
16
- ],
17
- "outboundTag": "api"
18
- },
19
- {
20
- "type": "field",
21
- "outboundTag": "blocked",
22
- "ip": [
23
- "geoip:private"
24
- ]
25
- },
26
- {
27
- "type": "field",
28
- "outboundTag": "blocked",
29
- "protocol": [
30
- "bittorrent"
31
- ]
32
- },
33
- {
34
- "type": "field",
35
- "network": "tcp,udp",
36
- "outboundTag": "warp-out"
37
- }
38
- ]
39
- },
40
- "dns": null,
41
- "inbounds": [
42
- {
43
- "listen": "127.0.0.1",
44
- "port": 62789,
45
- "protocol": "tunnel",
46
- "settings": {
47
- "address": "127.0.0.1"
48
- },
49
- "streamSettings": null,
50
- "tag": "api",
51
- "sniffing": null
52
- },
53
- {
54
- "tag": "vless-in",
55
- "port": 20001,
56
- "listen": "0.0.0.0",
57
- "protocol": "vless",
58
- "settings": {
59
- "clients": [
60
- {
61
- "id": "978b0df4-479f-452b-8cff-816ec34b04af",
62
- "email": "user@example.com"
63
- }
64
- ],
65
- "decryption": "none"
66
- },
67
- "streamSettings": {
68
- "network": "ws",
69
- "wsSettings": {
70
- "path": "/vds1client"
71
- }
72
- }
73
- }
74
- ],
75
- "outbounds": [
76
- {
77
- "tag": "direct",
78
- "protocol": "freedom",
79
- "settings": {
80
- "domainStrategy": "AsIs",
81
- "redirect": "",
82
- "noises": []
83
- }
84
- },
85
- {
86
- "tag": "blocked",
87
- "protocol": "blackhole",
88
- "settings": {}
89
- },
90
- {
91
- "protocol": "socks",
92
- "settings": {
93
- "servers": [
94
- {
95
- "address": "127.0.0.1",
96
- "port": 1080
97
- }
98
- ]
99
- },
100
- "tag": "warp-out"
101
- }
102
- ],
103
- "transport": null,
104
- "policy": {
105
- "levels": {
106
- "0": {
107
- "statsUserDownlink": true,
108
- "statsUserUplink": true
109
- }
110
- },
111
- "system": {
112
- "statsInboundDownlink": true,
113
- "statsInboundUplink": true,
114
- "statsOutboundDownlink": false,
115
- "statsOutboundUplink": false
116
- }
117
- },
118
- "api": {
119
- "tag": "api",
120
- "services": [
121
- "HandlerService",
122
- "LoggerService",
123
- "StatsService"
124
- ]
125
- },
126
- "stats": {},
127
- "reverse": null,
128
- "fakedns": null,
129
- "observatory": null,
130
- "burstObservatory": null,
131
- "metrics": {
132
- "tag": "metrics_out",
133
- "listen": "127.0.0.1:11111"
134
- }
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
x-ui-configs/x-ui.db DELETED
Binary file (53.2 kB)
 
x-ui-deployment-scheme.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # X-UI Deployment Scheme
2
+
3
+ This document outlines the architecture for deploying and accessing the X-UI web interface, leveraging Nginx for secure HTTPS access and Chisel for tunneling.
4
+
5
+ ## Components:
6
+
7
+ 1. **X-UI Docker Container:**
8
+ * Runs the X-UI application, listening on port `2053`.
9
+ * Includes a `chisel` client that establishes a reverse tunnel.
10
+
11
+ 2. **Chisel Client (inside Docker Container):**
12
+ * Connects to `vds1.iri1968.dpdns.org` on port `80`.
13
+ * Establishes a reverse tunnel: `R:8443:localhost:2053`. This means any traffic sent to `localhost:8443` on `vds1.iri1968.dpdns.org` will be forwarded to `localhost:2053` inside the Docker container (where X-UI is running).
14
+
15
+ 3. **Nginx on `vds1.iri1968.dpdns.org`:**
16
+ * **HTTPS Listener (Port 443):**
17
+ * Listens for secure HTTPS traffic on `vds1.iri1968.dpdns.org`.
18
+ * Uses Let's Encrypt SSL certificates for secure communication.
19
+ * Proxies all incoming requests to `http://localhost:8443` on the `vds1` server.
20
+ * Includes WebSocket support headers (`Upgrade` and `Connection: upgrade`) for proper X-UI panel and proxy traffic handling.
21
+ * **HTTP Listener (Port 80):**
22
+ * Listens for insecure HTTP traffic on `vds1.iri1968.dpdns.org`.
23
+ * Redirects all HTTP traffic to HTTPS (`https://$host$request_uri;`).
24
+
25
+ ## Access Flow:
26
+
27
+ 1. **User Access (Browser):**
28
+ * The user opens their web browser and navigates to `https://vds1.iri1968.dpdns.org`.
29
+
30
+ 2. **Nginx Processing (on `vds1.iri1968.dpdns.org`):**
31
+ * Nginx receives the HTTPS request on port `443`.
32
+ * It decrypts the SSL traffic using the configured certificates.
33
+ * Nginx then proxies this request internally to `http://localhost:8443` on the `vds1` server.
34
+
35
+ 3. **Chisel Server Processing (on `vds1.iri1968.dpdns.org`):**
36
+ * The `chisel` server (which is configured to listen on port `8443` due to the reverse tunnel initiated by the client in the Docker container) receives the request from Nginx.
37
+ * The `chisel` server forwards this request through the established `chisel` tunnel back to the `chisel` client running inside the Docker container.
38
+
39
+ 4. **Chisel Client & X-UI (inside Docker Container):**
40
+ * The `chisel` client inside the Docker container receives the request from the `chisel` server.
41
+ * It then forwards this request to `localhost:2053` within its own container, where the X-UI web interface is actively listening.
42
+ * X-UI processes the request and sends the response back through the same tunnel in reverse.
43
+
44
+ ## Summary of Access Points:
45
+
46
+ * **Primary Access (Recommended):** `https://vds1.iri1968.dpdns.org` (secure, external access via Nginx and Chisel tunnel).
47
+ * **Direct Container Access (Local Only):** `http://localhost:2053` (if the container's port 2053 is mapped to the host's 2053, for local testing/development).
48
+
49
+ This setup ensures secure, encrypted communication from the user's browser to the Nginx server, and then leverages the `chisel` tunnel for secure and reliable internal communication to the X-UI application, even if the X-UI container is behind a NAT or firewall.
x-ui.key ADDED
@@ -0,0 +1 @@
 
 
1
+ key