├── .github ├── dependabot.yml └── workflows │ ├── official.yml │ └── unofficial.yml ├── .gitignore ├── LICENSE ├── README.md ├── build_image ├── Dockerfile ├── Dockerfile.3x-ui ├── Dockerfile.alpha ├── Dockerfile.alpha-zh ├── Dockerfile.bestpractice ├── Dockerfile.beta ├── Dockerfile.bullseye ├── docker-compose.yml ├── get_xui_alpha.sh ├── get_xui_alpha_zh.sh └── get_xui_beta.sh ├── docker-compose.yml └── docs └── README_zh.md /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # GitHub Actions 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" -------------------------------------------------------------------------------- /.github/workflows/official.yml: -------------------------------------------------------------------------------- 1 | name: builder official 2 | on: 3 | workflow_dispatch: 4 | 5 | jobs: 6 | buildx: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v4 11 | with: 12 | submodules: true 13 | 14 | - name: Set up QEMU 15 | uses: docker/setup-qemu-action@v3 16 | 17 | - name: Set up Docker Buildx 18 | uses: docker/setup-buildx-action@v3 19 | 20 | - name: Cache Docker layers 21 | uses: actions/cache@v4 22 | with: 23 | path: /tmp/.buildx-cache 24 | key: ${{ runner.os }}-buildx-${{ github.sha }} 25 | restore-keys: | 26 | ${{ runner.os }}-buildx- 27 | 28 | - name: Login to DockerHub 29 | uses: docker/login-action@v3 30 | with: 31 | username: ${{ secrets.DOCKERHUB_USERNAME }} 32 | password: ${{ secrets.DOCKERHUB_TOKEN }} 33 | 34 | - name: Login to GitHub Container Registry 35 | uses: docker/login-action@v3 36 | with: 37 | registry: ghcr.io 38 | username: ${{ github.repository_owner }} 39 | password: ${{ secrets.GITHUB_TOKEN }} 40 | 41 | - name: Lower case dockerhub image name 42 | id: dockerhub_image 43 | uses: ASzc/change-string-case-action@v6 44 | with: 45 | string: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} 46 | 47 | - name: Lower case github docker image name 48 | id: ghcr_image 49 | uses: ASzc/change-string-case-action@v6 50 | with: 51 | string: ${{ github.repository }} 52 | 53 | - name: Build and push with latest tag 54 | uses: docker/build-push-action@v6 55 | with: 56 | context: build_image 57 | platforms: linux/amd64,linux/arm64,linux/s390x,linux/arm/v7 58 | push: true 59 | tags: | 60 | ${{ steps.dockerhub_image.outputs.lowercase }}:latest 61 | ghcr.io/${{ steps.ghcr_image.outputs.lowercase }}:latest 62 | cache-from: type=gha 63 | cache-to: type=gha,mode=max 64 | -------------------------------------------------------------------------------- /.github/workflows/unofficial.yml: -------------------------------------------------------------------------------- 1 | name: builder unofficial 2 | on: 3 | workflow_dispatch: 4 | 5 | jobs: 6 | buildx: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v4 11 | with: 12 | submodules: true 13 | 14 | - name: Set up QEMU 15 | uses: docker/setup-qemu-action@v3 16 | 17 | - name: Set up Docker Buildx 18 | uses: docker/setup-buildx-action@v3 19 | 20 | - name: Cache Docker layers 21 | uses: actions/cache@v4 22 | with: 23 | path: /tmp/.buildx-cache 24 | key: ${{ runner.os }}-buildx-${{ github.sha }} 25 | restore-keys: | 26 | ${{ runner.os }}-buildx- 27 | 28 | - name: Login to DockerHub 29 | uses: docker/login-action@v3 30 | with: 31 | username: ${{ secrets.DOCKERHUB_USERNAME }} 32 | password: ${{ secrets.DOCKERHUB_TOKEN }} 33 | 34 | - name: Login to GitHub Container Registry 35 | uses: docker/login-action@v3 36 | with: 37 | registry: ghcr.io 38 | username: ${{ github.repository_owner }} 39 | password: ${{ secrets.GITHUB_TOKEN }} 40 | 41 | - name: Lower case dockerhub image name 42 | id: dockerhub_image 43 | uses: ASzc/change-string-case-action@v6 44 | with: 45 | string: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} 46 | 47 | - name: Lower case github docker image name 48 | id: ghcr_image 49 | uses: ASzc/change-string-case-action@v6 50 | with: 51 | string: ${{ github.repository }} 52 | 53 | - name: Build and push with alpha tag 54 | uses: docker/build-push-action@v6 55 | with: 56 | context: build_image 57 | file: ./build_image/Dockerfile.alpha 58 | platforms: linux/amd64,linux/arm64,linux/s390x 59 | push: true 60 | tags: | 61 | ${{ steps.dockerhub_image.outputs.lowercase }}:alpha 62 | ghcr.io/${{ steps.ghcr_image.outputs.lowercase }}:alpha 63 | cache-from: type=local,src=/tmp/.buildx-cache 64 | cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max 65 | 66 | - name: Build and push with alpha-zh tag 67 | uses: docker/build-push-action@v6 68 | with: 69 | context: build_image 70 | file: ./build_image/Dockerfile.alpha-zh 71 | platforms: linux/amd64,linux/arm64,linux/s390x 72 | push: true 73 | tags: | 74 | ${{ steps.dockerhub_image.outputs.lowercase }}:alpha-zh 75 | ghcr.io/${{ steps.ghcr_image.outputs.lowercase }}:alpha-zh 76 | cache-from: type=local,src=/tmp/.buildx-cache 77 | cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max 78 | 79 | - name: Build and push with 3x-ui 80 | uses: docker/build-push-action@v6 81 | with: 82 | context: build_image 83 | file: ./build_image/Dockerfile.3x-ui 84 | platforms: linux/amd64,linux/arm64,linux/s390x 85 | push: true 86 | tags: | 87 | ${{ steps.dockerhub_image.outputs.lowercase }}:3x-ui 88 | ghcr.io/${{ steps.ghcr_image.outputs.lowercase }}:3x-ui 89 | cache-from: type=gha 90 | cache-to: type=gha,mode=max 91 | 92 | - name: Sync README.md 93 | uses: ms-jpq/sync-dockerhub-readme@v1 94 | with: 95 | username: ${{ secrets.DOCKERHUB_USERNAME }} 96 | password: ${{ secrets.DOCKERHUB_TOKEN }} 97 | repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} 98 | readme: "./docs/README_zh.md" 99 | 100 | - name: Move cache 101 | run: | 102 | rm -rf /tmp/.buildx-cache 103 | mv /tmp/.buildx-cache-new /tmp/.buildx-cache 104 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | *.crt 3 | *.key 4 | db/ 5 | cert/ 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 LuckyHunter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # x-ui docker image 2 | 3 | 4 | 5 | [![Docker Pulls][docker-pulls-shield]][docker-pulls-url] 6 | [![Contributors][contributors-shield]][contributors-url] 7 | [![Forks][forks-shield]][forks-url] 8 | [![Stargazers][stars-shield]][stars-url] 9 | [![Issues][issues-shield]][issues-url] 10 | [![MIT License][license-shield]][license-url] 11 | 12 | [docker-pulls-shield]: https://img.shields.io/docker/pulls/enwaiax/x-ui.svg?style=flat-square 13 | [docker-pulls-url]: https://hub.docker.com/r/enwaiax/x-ui 14 | [contributors-shield]: https://img.shields.io/github/contributors/enwaiax/x-ui.svg?style=flat-square 15 | [contributors-url]: https://github.com/enwaiax/x-ui/graphs/contributors 16 | [forks-shield]: https://img.shields.io/github/forks/enwaiax/x-ui.svg?style=flat-square 17 | [forks-url]: https://github.com/enwaiax/x-ui/network/members 18 | [stars-shield]: https://img.shields.io/github/stars/enwaiax/x-ui.svg?style=flat-square 19 | [stars-url]: https://github.com/enwaiax/x-ui/stargazers 20 | [issues-shield]: https://img.shields.io/github/issues/enwaiax/x-ui.svg?style=flat-square 21 | [issues-url]: https://github.com/enwaiax/x-ui/issues 22 | [license-shield]: https://img.shields.io/github/license/enwaiax/x-ui.svg?style=flat-square 23 | [license-url]: https://github.com/enwaiax/x-ui/blob/main/LICENSE 24 | 25 | [English](README.md) | [中文文档](./docs/README_zh.md) 26 | 27 | > x-ui in docker version 28 | 29 | You could selecet your perfer one by changing the docker image tag 30 | 31 | | | Tag | amd64 | arm64 | armv7 | s390x | 32 | | ---------------------------------------------------------- | ------ | ----- | ----- | ----- | ----- | 33 | | [vaxilu/x-ui](https://github.com/vaxilu/x-ui) | latest | ✅ | ✅ | ✅ | ✅ | 34 | | [FranzKafkaYu/x-ui](https://github.com/FranzKafkaYu/x-ui) | alpha | ✅ | ✅ | ❌ | ✅ | 35 | | [X-UI-Unofficial/x-ui](https://github.com/X-UI-Unofficial) | beta | ✅ | ✅ | ❌ | ✅ | 36 | | [MHSanaei/3x-ui](https://github.com/MHSanaei/3x-ui) | 3x-ui | ✅ | ✅ | ✅ | ✅ | 37 | 38 | ### Why Should You Use Docker 39 | 40 | - Consistent & Isolated Environment 41 | - Rapid Application Deployment 42 | - Ensures Scalability & Flexibility 43 | - Better Portability 44 | - Cost-Effective 45 | - In-Built Version Control System 46 | - Security 47 | - ..... 48 | 49 | ### For this project, if you use docker 50 | 51 | - You don't need to concern yourself with operating systems, architectures and other issues. 52 | - You will never ruin your Linux server. If you don't want to use it, you can stop or remove it from your environment exactly. 53 | - Last but not least, you can easily deploy and upgrade 54 | 55 | ### Hot to use it 56 | 57 | #### Pre-condition, Docker is installed 58 | 59 | Use the official one-key script 60 | 61 | ```bash 62 | curl -sSL https://get.docker.com/ | sh 63 | ``` 64 | 65 | #### Start you container 66 | 67 | ##### You could use the pre-build docker image enwaiax/xuiplus 68 | 69 | ``` 70 | mkdir x-ui && cd x-ui 71 | docker run -itd --network=host \ 72 | -v $PWD/db/:/etc/x-ui/ \ 73 | -v $PWD/cert/:/root/cert/ \ 74 | --name x-ui --restart=unless-stopped \ 75 | enwaiax/x-ui 76 | ``` 77 | 78 | Note: If you want to use [FranzKafkaYu/x-ui](https://github.com/FranzKafkaYu/x-ui), change the image as `enwaiax/x-ui:alpha` 79 | 80 | ##### Or you could use docker compose to start it 81 | 82 | ``` 83 | mkdir x-ui && cd x-ui 84 | wget https://raw.githubusercontent.com/enwaiax/x-ui/main/docker-compose.yml 85 | docker compose up -d 86 | ``` 87 | 88 | #### How to enable ssl to your x-ui panel 89 | 90 | This part describe how to enable ssl. 91 | 92 | - Suppose your x-ui port is `54321` 93 | - Suppose your IP is `10.10.10.10` 94 | - Suppose your domain is `xui.example.com` and you have set the A recode in cloudflare 95 | - Suppose you are using Debian 10+ or Ubuntu 18+ system 96 | - Suppose your email is `xxxx@example.com` 97 | 98 | ##### Steps as below 99 | 100 | 1. Install nginx and python3-certbot-nginx 101 | 102 | ```bash 103 | sudo apt update 104 | sudo apt install python3-certbot-nginx 105 | ``` 106 | 107 | 2. Add new nging configurtion 108 | 109 | ``` 110 | touch /etc/nginx/conf.d/xui.conf 111 | ``` 112 | 113 | Add below to the file. Adjust appropriately to your own situation. 114 | 115 | ```nginx 116 | server { 117 | listen 80; 118 | listen [::]:80; 119 | server_name xui.example.com; 120 | 121 | location / { 122 | proxy_redirect off; 123 | proxy_pass http://127.0.0.1:54321; 124 | proxy_http_version 1.1; 125 | proxy_set_header Host $host; 126 | } 127 | 128 | # This part desribe how to reverse websockt proxy 129 | location /xray { 130 | proxy_redirect off; 131 | proxy_pass http://127.0.0.1:10001; 132 | proxy_http_version 1.1; 133 | proxy_set_header Upgrade $http_upgrade; 134 | proxy_set_header Connection "upgrade"; 135 | proxy_set_header X-Real-IP $remote_addr; 136 | proxy_set_header Host $http_host; 137 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 138 | proxy_set_header Y-Real-IP $realip_remote_addr; 139 | } 140 | } 141 | ``` 142 | 143 | 3. Check yout conf is OK 144 | 145 | ``` 146 | nginx -t 147 | ``` 148 | 149 | 4. Get cert 150 | 151 | ``` 152 | certbot --nginx --agree-tos --no-eff-email --email xxxxx@example.com 153 | ``` 154 | 155 | For more details, refer to [cerbot](https://certbot.eff.org/) 156 | 157 | 5. Reload nginx config 158 | 159 | ``` 160 | nginx -s reload 161 | ``` 162 | 163 | 6. Test automatic renewal 164 | 165 | ``` 166 | sudo certbot renew --dry-run 167 | ``` 168 | 169 | Note: Default credentials 170 | 171 | Username: `admin` 172 | 173 | Password: `admin` 174 | -------------------------------------------------------------------------------- /build_image/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.23-alpine AS builder 3 | 4 | ARG XUI_REPO="https://github.com/vaxilu/x-ui" 5 | 6 | # Install build dependencies 7 | RUN apk add --no-cache --update \ 8 | build-base \ 9 | gcc \ 10 | git \ 11 | && git clone ${XUI_REPO} --depth=1 /go/x-ui 12 | 13 | WORKDIR /go/x-ui 14 | 15 | # Build with proper flags and optimizations 16 | ENV CGO_ENABLED=1 \ 17 | CGO_CFLAGS="-D_LARGEFILE64_SOURCE" \ 18 | GO111MODULE=on \ 19 | GOOS=linux 20 | 21 | RUN go build -a -trimpath \ 22 | -ldflags "-s -w -linkmode external -extldflags '-static'" \ 23 | -o x-ui 24 | 25 | # Final stage 26 | FROM alpine:latest 27 | 28 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" 29 | 30 | # Set timezone and install necessary packages 31 | ENV TZ=Asia/Shanghai 32 | 33 | RUN apk add --no-cache \ 34 | ca-certificates \ 35 | tzdata \ 36 | && cp /usr/share/zoneinfo/${TZ} /etc/localtime \ 37 | && echo "${TZ}" > /etc/timezone \ 38 | && rm -rf /var/cache/apk/* 39 | 40 | # Copy binary from builder 41 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 42 | 43 | # Copy Xray binary and resources based on architecture 44 | ARG TARGETARCH 45 | COPY --from=teddysun/xray /usr/bin/xray /usr/local/bin/bin/xray-linux-${TARGETARCH} 46 | COPY --from=teddysun/xray /usr/share/xray/ /usr/local/bin/bin/ 47 | 48 | # Set up volume and working directory 49 | VOLUME ["/etc/x-ui"] 50 | WORKDIR /usr/local/bin 51 | 52 | # Health check 53 | HEALTHCHECK --interval=30s --timeout=3s \ 54 | CMD wget --no-verbose --tries=1 --spider http://localhost:54321 || exit 1 55 | 56 | # Expose necessary ports (customize as needed) 57 | EXPOSE 54321 58 | 59 | CMD ["x-ui"] -------------------------------------------------------------------------------- /build_image/Dockerfile.3x-ui: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.23-alpine AS builder 3 | 4 | ARG XUI_REPO="https://github.com/MHSanaei/3x-ui.git" 5 | 6 | # Install build dependencies 7 | RUN apk add --no-cache --update \ 8 | build-base \ 9 | gcc \ 10 | git \ 11 | && git clone ${XUI_REPO} --depth=1 /go/x-ui 12 | 13 | WORKDIR /go/x-ui 14 | 15 | # Build with proper flags and optimizations 16 | ENV CGO_ENABLED=1 \ 17 | CGO_CFLAGS="-D_LARGEFILE64_SOURCE" \ 18 | GO111MODULE=on \ 19 | GOOS=linux 20 | 21 | RUN go build -a -trimpath \ 22 | -ldflags "-s -w -linkmode external -extldflags '-static'" \ 23 | -o x-ui 24 | 25 | # Final stage 26 | FROM alpine:latest 27 | 28 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" 29 | 30 | # Set timezone and install necessary packages 31 | ENV TZ=Asia/Shanghai 32 | 33 | RUN apk add --no-cache \ 34 | ca-certificates \ 35 | tzdata \ 36 | && cp /usr/share/zoneinfo/${TZ} /etc/localtime \ 37 | && echo "${TZ}" > /etc/timezone \ 38 | && rm -rf /var/cache/apk/* 39 | 40 | # Copy binary from builder 41 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 42 | 43 | # Copy Xray binary and resources based on architecture 44 | ARG TARGETARCH 45 | COPY --from=teddysun/xray /usr/bin/xray /usr/local/bin/bin/xray-linux-${TARGETARCH} 46 | COPY --from=teddysun/xray /usr/share/xray/ /usr/local/bin/bin/ 47 | 48 | # Set up volume and working directory 49 | VOLUME ["/etc/x-ui"] 50 | WORKDIR /usr/local/bin 51 | 52 | # Health check 53 | HEALTHCHECK --interval=30s --timeout=3s \ 54 | CMD wget --no-verbose --tries=1 --spider http://localhost:2053 || exit 1 55 | 56 | # Expose necessary ports (customize as needed) 57 | EXPOSE 2053 58 | 59 | CMD ["x-ui"] -------------------------------------------------------------------------------- /build_image/Dockerfile.alpha: -------------------------------------------------------------------------------- 1 | FROM golang:latest AS builder 2 | COPY get_xui_alpha.sh get_xui.sh 3 | RUN bash get_xui.sh 4 | 5 | FROM debian:12-slim 6 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" 7 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 8 | 9 | ENV DEBIAN_FRONTEND=noninteractive, TZ=Asia/Shanghai 10 | RUN apt-get update \ 11 | && apt-get install -y --no-install-recommends -y ca-certificates \ 12 | && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 13 | 14 | ARG TARGETARCH 15 | COPY --from=teddysun/xray /usr/bin/xray /usr/local/bin/bin/xray-linux-${TARGETARCH} 16 | COPY --from=teddysun/xray /usr/share/xray/ /usr/local/bin/bin/ 17 | 18 | VOLUME [ "/etc/x-ui" ] 19 | WORKDIR /usr/local/bin 20 | CMD [ "x-ui" ] 21 | -------------------------------------------------------------------------------- /build_image/Dockerfile.alpha-zh: -------------------------------------------------------------------------------- 1 | FROM golang:latest AS builder 2 | COPY get_xui_alpha_zh.sh get_xui.sh 3 | RUN bash get_xui.sh 4 | 5 | FROM debian:12-slim 6 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" 7 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 8 | 9 | ENV DEBIAN_FRONTEND=noninteractive, TZ=Asia/Shanghai 10 | RUN apt-get update \ 11 | && apt-get install -y --no-install-recommends -y ca-certificates \ 12 | && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 13 | 14 | ARG TARGETARCH 15 | COPY --from=teddysun/xray /usr/bin/xray /usr/local/bin/bin/xray-linux-${TARGETARCH} 16 | COPY --from=teddysun/xray /usr/share/xray/ /usr/local/bin/bin/ 17 | 18 | VOLUME [ "/etc/x-ui" ] 19 | WORKDIR /usr/local/bin 20 | CMD [ "x-ui" ] 21 | -------------------------------------------------------------------------------- /build_image/Dockerfile.bestpractice: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.23-alpine AS builder 3 | 4 | ARG XUI_REPO="https://github.com/vaxilu/x-ui" 5 | 6 | # Install build dependencies 7 | RUN apk add --no-cache --update \ 8 | build-base \ 9 | gcc \ 10 | git \ 11 | && git clone ${XUI_REPO} --depth=1 /go/x-ui 12 | 13 | WORKDIR /go/x-ui 14 | 15 | # Build with proper flags and optimizations 16 | ENV CGO_ENABLED=1 \ 17 | CGO_CFLAGS="-D_LARGEFILE64_SOURCE" \ 18 | GO111MODULE=on \ 19 | GOOS=linux 20 | 21 | RUN go build -a -trimpath \ 22 | -ldflags "-s -w -linkmode external -extldflags '-static'" \ 23 | -o x-ui 24 | 25 | # Final stage 26 | FROM alpine:3.19 27 | 28 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" \ 29 | org.opencontainers.image.description="X-UI Panel Docker Image" \ 30 | org.opencontainers.image.source="https://github.com/vaxilu/x-ui" 31 | 32 | # Set timezone and install necessary packages 33 | ENV TZ=Asia/Shanghai 34 | 35 | RUN apk add --no-cache \ 36 | ca-certificates \ 37 | tzdata \ 38 | && cp /usr/share/zoneinfo/${TZ} /etc/localtime \ 39 | && echo "${TZ}" > /etc/timezone \ 40 | && rm -rf /var/cache/apk/* 41 | 42 | # Copy binary from builder 43 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 44 | 45 | # Copy Xray binary and resources based on architecture 46 | ARG TARGETARCH 47 | COPY --from=teddysun/xray --chown=nobody:nogroup \ 48 | /usr/bin/xray /usr/local/bin/bin/xray-linux-${TARGETARCH} 49 | COPY --from=teddysun/xray --chown=nobody:nogroup \ 50 | /usr/share/xray/ /usr/local/bin/bin/ 51 | 52 | # Create non-root user 53 | RUN adduser -D -H -s /sbin/nologin xui && \ 54 | chmod +x /usr/local/bin/x-ui 55 | 56 | # Set up volume and working directory 57 | VOLUME ["/etc/x-ui"] 58 | WORKDIR /usr/local/bin 59 | 60 | # Switch to non-root user 61 | USER xui 62 | 63 | # Health check 64 | HEALTHCHECK --interval=30s --timeout=3s \ 65 | CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT:-54321}/login || exit 1 66 | 67 | # Expose necessary ports (customize as needed) 68 | EXPOSE 54321 69 | 70 | CMD ["x-ui"] -------------------------------------------------------------------------------- /build_image/Dockerfile.beta: -------------------------------------------------------------------------------- 1 | FROM golang:latest AS builder 2 | COPY get_xui_beta.sh get_xui.sh 3 | RUN bash get_xui.sh 4 | 5 | FROM debian:11-slim 6 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" 7 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 8 | 9 | ENV DEBIAN_FRONTEND=noninteractive, TZ=Asia/Shanghai 10 | RUN apt-get update \ 11 | && apt-get install -y --no-install-recommends -y ca-certificates \ 12 | && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 13 | 14 | ARG TARGETARCH 15 | COPY --from=builder /go/x-ui/bin/xray-linux-${TARGETARCH} /usr/local/bin/bin/xray-linux-${TARGETARCH} 16 | COPY --from=teddysun/xray /usr/share/xray/ /usr/local/bin/bin/ 17 | 18 | VOLUME [ "/etc/x-ui" ] 19 | WORKDIR /usr/local/bin 20 | CMD [ "x-ui" ] 21 | -------------------------------------------------------------------------------- /build_image/Dockerfile.bullseye: -------------------------------------------------------------------------------- 1 | FROM golang:bullseye AS builder 2 | ARG XUI_REPO="https://github.com/vaxilu/x-ui" 3 | RUN git clone ${XUI_REPO} --depth=1 4 | WORKDIR /go/x-ui 5 | RUN go build -a -ldflags "-linkmode external -extldflags '-static' -s -w" 6 | 7 | FROM debian:12-slim 8 | LABEL org.opencontainers.image.authors="https://github.com/enwaiax" 9 | COPY --from=builder /go/x-ui/x-ui /usr/local/bin/x-ui 10 | 11 | ENV DEBIAN_FRONTEND=noninteractive, TZ=Asia/Shanghai 12 | RUN apt-get update \ 13 | && apt-get install -y --no-install-recommends -y ca-certificates \ 14 | && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 15 | 16 | ARG TARGETARCH 17 | COPY --from=teddysun/xray /usr/bin/xray /usr/local/bin/bin/xray-linux-${TARGETARCH} 18 | COPY --from=teddysun/xray /usr/share/xray/ /usr/local/bin/bin/ 19 | 20 | VOLUME [ "/etc/x-ui" ] 21 | WORKDIR /usr/local/bin 22 | CMD [ "x-ui" ] 23 | -------------------------------------------------------------------------------- /build_image/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | xui: 3 | build: 4 | context: . 5 | dockerfile: Dockerfile.alpha 6 | image: enwaiax/x-ui 7 | container_name: xui 8 | restart: unless-stopped 9 | network_mode: host 10 | volumes: 11 | - $PWD/db/:/etc/x-ui/ 12 | - $PWD/cert/:/root/cert/ 13 | -------------------------------------------------------------------------------- /build_image/get_xui_alpha.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | plain='\033[0m' 6 | 7 | arch=$(arch) 8 | 9 | if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then 10 | arch="amd64" 11 | elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then 12 | arch="arm64" 13 | elif [[ $arch == "s390x" ]]; then 14 | arch="s390x" 15 | else 16 | echo -e "${red}Failed to detect schema, use default schema: ${arch}${plain}" 17 | fi 18 | 19 | echo "Your CPU arch: ${arch}" 20 | 21 | install_x-ui() { 22 | mkdir -p /go 23 | cd /go || exit 24 | last_version=$(curl -Ls "https://api.github.com/repos/FranzKafkaYu/x-ui/releases/latest" | 25 | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 26 | if [[ -z "$last_version" ]]; then 27 | echo -e "${red}GitHub API limitation, please try it later${plain}" 28 | exit 1 29 | fi 30 | echo -e "x-ui version: ${last_version}, start installation" 31 | wget -q -N --no-check-certificate \ 32 | -O x-ui-linux-"${arch}".tar.gz \ 33 | https://github.com/FranzKafkaYu/x-ui/releases/download/"${last_version}"/x-ui-linux-"${arch}"-english.tar.gz 34 | if [[ $? -ne 0 ]]; then 35 | echo -e "${red}Failed to download x-ui${plain}" 36 | exit 1 37 | fi 38 | tar zxvf x-ui-linux-"${arch}".tar.gz 39 | chmod +x x-ui/x-ui 40 | } 41 | 42 | echo -e "${green}Get x-ui binary file${plain}" 43 | install_x-ui 44 | -------------------------------------------------------------------------------- /build_image/get_xui_alpha_zh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | plain='\033[0m' 6 | 7 | arch=$(arch) 8 | 9 | if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then 10 | arch="amd64" 11 | elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then 12 | arch="arm64" 13 | elif [[ $arch == "s390x" ]]; then 14 | arch="s390x" 15 | else 16 | echo -e "${red}Failed to detect schema, use default schema: ${arch}${plain}" 17 | fi 18 | 19 | echo "Your CPU arch: ${arch}" 20 | 21 | install_x-ui() { 22 | mkdir -p /go 23 | cd /go || exit 24 | last_version=$(curl -Ls "https://api.github.com/repos/FranzKafkaYu/x-ui/releases/latest" | 25 | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 26 | if [[ -z "$last_version" ]]; then 27 | echo -e "${red}GitHub API limitation, please try it later${plain}" 28 | exit 1 29 | fi 30 | echo -e "x-ui version: ${last_version}, start installation" 31 | wget -q -N --no-check-certificate \ 32 | -O x-ui-linux-"${arch}".tar.gz \ 33 | https://github.com/FranzKafkaYu/x-ui/releases/download/"${last_version}"/x-ui-linux-"${arch}".tar.gz 34 | if [[ $? -ne 0 ]]; then 35 | echo -e "${red}Failed to download x-ui${plain}" 36 | exit 1 37 | fi 38 | tar zxvf x-ui-linux-"${arch}".tar.gz 39 | chmod +x x-ui/x-ui 40 | } 41 | 42 | echo -e "${green}Get x-ui binary file${plain}" 43 | install_x-ui 44 | -------------------------------------------------------------------------------- /build_image/get_xui_beta.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red='\033[0;31m' 4 | green='\033[0;32m' 5 | plain='\033[0m' 6 | 7 | arch=$(arch) 8 | 9 | if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then 10 | arch="x86_64" 11 | elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then 12 | arch="aarch64" 13 | elif [[ $arch == "s390x" ]]; then 14 | arch="s390x" 15 | elif [[ $arch == "riscv64" ]]; then 16 | arch="riscv64" 17 | else 18 | exit 1 19 | fi 20 | 21 | echo "Your CPU arch: ${arch}" 22 | 23 | install_x-ui() { 24 | mkdir -p /go 25 | cd /go || exit 26 | last_version=$(curl -Ls "https://api.github.com/repos/X-UI-Unofficial/release/releases/latest" | 27 | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 28 | if [[ -z "$last_version" ]]; then 29 | echo -e "${red}GitHub API limitation, please try it later${plain}" 30 | exit 1 31 | fi 32 | echo -e "x-ui version: ${last_version}, start installation" 33 | wget -q -N --no-check-certificate \ 34 | -O x-ui-linux-${arch}.tar.gz \ 35 | https://github.com/X-UI-Unofficial/release/releases/download/"${last_version}"/x-ui-linux-${arch}.tar.gz 36 | if [[ $? -ne 0 ]]; then 37 | echo -e "${red}Failed to download x-ui${plain}" 38 | exit 1 39 | fi 40 | tar zxvf x-ui-linux-${arch}.tar.gz 41 | cd x-ui || exit 42 | chmod +x x-ui bin/xray-linux-${arch} 43 | if [[ $arch == "aarch64" || $arch == "arm64" ]]; then 44 | mv bin/xray-linux-aarch64 bin/xray-linux-arm64 45 | elif [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then 46 | mv bin/xray-linux-x86_64 bin/xray-linux-amd64 47 | fi 48 | } 49 | 50 | echo -e "${green}Get x-ui binary file${plain}" 51 | install_x-ui 52 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | xui: 3 | image: enwaiax/x-ui 4 | container_name: xui 5 | volumes: 6 | - $PWD/db/:/etc/x-ui/ 7 | - $PWD/cert/:/root/cert/ 8 | restart: unless-stopped 9 | network_mode: host 10 | -------------------------------------------------------------------------------- /docs/README_zh.md: -------------------------------------------------------------------------------- 1 | # x-ui docker image 2 | 3 | 4 | 5 | [![Docker Pulls][docker-pulls-shield]][docker-pulls-url] 6 | [![Contributors][contributors-shield]][contributors-url] 7 | [![Forks][forks-shield]][forks-url] 8 | [![Stargazers][stars-shield]][stars-url] 9 | [![Issues][issues-shield]][issues-url] 10 | [![MIT License][license-shield]][license-url] 11 | 12 | [docker-pulls-shield]: https://img.shields.io/docker/pulls/enwaiax/x-ui.svg?style=flat-square 13 | [docker-pulls-url]: https://hub.docker.com/r/enwaiax/x-ui 14 | [contributors-shield]: https://img.shields.io/github/contributors/enwaiax/x-ui.svg?style=flat-square 15 | [contributors-url]: https://github.com/enwaiax/x-ui/graphs/contributors 16 | [forks-shield]: https://img.shields.io/github/forks/enwaiax/x-ui.svg?style=flat-square 17 | [forks-url]: https://github.com/enwaiax/x-ui/network/members 18 | [stars-shield]: https://img.shields.io/github/stars/enwaiax/x-ui.svg?style=flat-square 19 | [stars-url]: https://github.com/enwaiax/x-ui/stargazers 20 | [issues-shield]: https://img.shields.io/github/issues/enwaiax/x-ui.svg?style=flat-square 21 | [issues-url]: https://github.com/enwaiax/x-ui/issues 22 | [license-shield]: https://img.shields.io/github/license/enwaiax/x-ui.svg?style=flat-square 23 | [license-url]: https://github.com/enwaiax/x-ui/blob/main/LICENSE 24 | 25 | > x-ui docker 版本 26 | 27 | 可以通过使用不同的`tag`来使用不同作者的镜像 28 | 29 | | | Tag | amd64 | arm64 | armv7 | s390x | 30 | | ---------------------------------------------------------- | -------- | ----- | ----- | ----- | ----- | 31 | | [vaxilu/x-ui](https://github.com/vaxilu/x-ui) | latest | ✅ | ✅ | ✅ | ✅ | 32 | | [FranzKafkaYu/x-ui](https://github.com/FranzKafkaYu/x-ui) | alpha-zh | ✅ | ✅ | ❌ | ✅ | 33 | | [X-UI-Unofficial/x-ui](https://github.com/X-UI-Unofficial) | beta | ✅ | ✅ | ❌ | ✅ | 34 | | [MHSanaei/3x-ui](https://github.com/MHSanaei/3x-ui) | 3x-ui | ✅ | ✅ | ✅ | ✅ | 35 | 36 | ### 为什么要使用`docker` 37 | 38 | - 一致性且能保证环境隔离 39 | - 快速部署 40 | - 保证灵活性和扩展性 41 | - 更好的可移植性 42 | - 低成本 43 | - 方便控制版本 44 | - 安全 45 | - ..... 46 | 47 | ### 对于 x-ui,如果使用 docker 48 | 49 | - 无需关心原宿主机的系统,架构,版本 50 | - 不会破坏原系统,如果不想使用,很方便就能完全干净的卸载 51 | - 部署方便且容易升级 52 | 53 | ### 如何使用 54 | 55 | #### 前提:安装好 docker 56 | 57 | 使用官方一键脚本 58 | 59 | ```bash 60 | curl -sSL https://get.docker.com/ | sh 61 | ``` 62 | 63 | #### 运行你的容器 64 | 65 | ##### 使用 [vaxilu/x-ui](https://github.com/vaxilu/x-ui) 版本的 66 | 67 | ``` 68 | mkdir x-ui && cd x-ui 69 | docker run -itd --network=host \ 70 | -v $PWD/db/:/etc/x-ui/ \ 71 | -v $PWD/cert/:/root/cert/ \ 72 | --name x-ui --restart=unless-stopped \ 73 | enwaiax/x-ui 74 | ``` 75 | 76 | 注意: 如果希望使用[FranzKafkaYu/x-ui](https://github.com/FranzKafkaYu/x-ui)版本,仅需要讲上述镜像修改为 `enwaiax/x-ui:alpha-zh` 77 | 78 | ##### 使用 docker-compose 运行 79 | 80 | ``` 81 | mkdir x-ui && cd x-ui 82 | wget https://raw.githubusercontent.com//enwaiax/x-ui/main/docker-compose.yml 83 | docker compose up -d 84 | ``` 85 | 86 | #### 如何启用 ssl 87 | 88 | - 假设你的 x-ui 端口是 `54321` 89 | - 假设你的 IP 是 `10.10.10.10` 90 | - 假设你的域名是 `xui.example.com`,且已经做好 A 记录解析 91 | - 假设你使用的是 Debian 10+或者 Ubuntu 18+的系统 92 | - 假设你的邮箱是 `xxxx@example.com` 93 | 94 | ##### 步骤如下 95 | 96 | 1. 安装必要软件 97 | 98 | ```bash 99 | sudo apt update 100 | sudo apt install snapd nginx 101 | sudo snap install core 102 | sudo snap refresh core 103 | sudo snap install --classic certbot 104 | sudo ln -s /snap/bin/certbot /usr/bin/certbot 105 | ``` 106 | 107 | 2. 新建一个 nginx 配置 108 | 109 | ``` 110 | touch /etc/nginx/conf.d/xui.conf 111 | ``` 112 | 113 | 增加以下配置,按照实际情况调整 114 | 115 | ```nginx 116 | server { 117 | listen 80; 118 | listen [::]:80; 119 | server_name xui.example.com; 120 | 121 | location / { 122 | proxy_redirect off; 123 | proxy_pass http://127.0.0.1:54321; 124 | proxy_http_version 1.1; 125 | proxy_set_header Host $host; 126 | } 127 | 128 | # 反代websocket 129 | location /xray { 130 | proxy_redirect off; 131 | proxy_pass http://127.0.0.1:10001; 132 | proxy_http_version 1.1; 133 | proxy_set_header Upgrade $http_upgrade; 134 | proxy_set_header Connection "upgrade"; 135 | proxy_set_header X-Real-IP $remote_addr; 136 | proxy_set_header Host $http_host; 137 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 138 | proxy_set_header Y-Real-IP $realip_remote_addr; 139 | } 140 | } 141 | ``` 142 | 143 | 3. 检查配置是否正常 144 | 145 | ``` 146 | nginx -t 147 | ``` 148 | 149 | 4. 申请证书,按照提示设置 150 | 151 | ``` 152 | certbot --nginx --agree-tos --no-eff-email --email xxxxx@example.com 153 | ``` 154 | 155 | 更多细节可以参考 [cerbot](https://certbot.eff.org/) 156 | 157 | 5. 刷新 nginx 配置生效 158 | 159 | ``` 160 | ngins -s reload 161 | ``` 162 | 163 | 6. 配置定时任务 164 | 165 | ``` 166 | sudo certbot renew --dry-run 167 | ``` 168 | --------------------------------------------------------------------------------