9

docker安装x-ui&x-ui魔改版|docker-compose

 1 year ago
source link: https://vpsxb.net/4347/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

x-ui docker image

202304242302050.png

x-ui docker 版本

可以通过使用不同的tag来使用不同作者的镜像

Tag amd64 arm64 armv7 s390x
vaxilu/x-ui latest
FranzKafkaYu/x-ui alpha-zh
X-UI-Unofficial/x-ui beta

为什么要使用docker

  • 一致性且能保证环境隔离
  • 保证灵活性和扩展性
  • 更好的可移植性
  • 方便控制版本

对于 x-ui,如果使用 docker

  • 无需关心原宿主机的系统,架构,版本
  • 不会破坏原系统,如果不想使用,很方便就能完全干净的卸载
  • 部署方便且容易升级

前提:安装好 docker

使用官方一键脚本



  1. curl -sSL https://get.docker.com/ | sh

运行你的容器

使用 vaxilu/x-ui 版本的


  1. mkdir x-ui && cd x-ui
  2. docker run -itd --network=host \
  3. -v $PWD/db/:/etc/x-ui/ \
  4. -v $PWD/cert/:/root/cert/ \
  5. --name x-ui --restart=unless-stopped \
  6. enwaiax/x-ui

注意: 如果希望使用FranzKafkaYu/x-ui版本,仅需要讲上述镜像修改为 enwaiax/x-ui:alpha-zh

使用 docker-compose 运行


  1. mkdir x-ui && cd x-ui
  2. wget https://raw.githubusercontent.com//chasing66/x-ui/main/docker-compose.yml
  3. docker compose up -d

如何启用 ssl

  • 假设你的 x-ui 端口是 54321
  • 假设你的 IP 是 10.10.10.10
  • 假设你的域名是 xui.example.com,且已经做好 A 记录解析
  • 假设你使用的是 Debian 10+或者 Ubuntu 18+的系统
  • 假设你的邮箱是 [email protected]
  1. 安装必要软件


  1. sudo apt update
  2. sudo apt install snapd nginx
  3. sudo snap install core
  4. sudo snap refresh core
  5. sudo snap install --classic certbot
  6. sudo ln -s /snap/bin/certbot /usr/bin/certbot
  1. 新建一个 nginx 配置


  1. touch /etc/nginx/conf.d/xui.conf

增加以下配置,按照实际情况调整



  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name xui.example.com;
  5. location / {
  6. proxy_redirect off;
  7. proxy_pass http://127.0.0.1:54321;
  8. proxy_http_version 1.1;
  9. proxy_set_header Host $host;
  10. }
  11. # 反代websocket
  12. location /xray {
  13. proxy_redirect off;
  14. proxy_pass http://127.0.0.1:10001;
  15. proxy_http_version 1.1;
  16. proxy_set_header Upgrade $http_upgrade;
  17. proxy_set_header Connection "upgrade";
  18. proxy_set_header X-Real-IP $remote_addr;
  19. proxy_set_header Host $http_host;
  20. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  21. proxy_set_header Y-Real-IP $realip_remote_addr;
  22. }
  23. }
  1. 检查配置是否正常


  1. nginx -t
  1. 申请证书,按照提示设置


  1. certbot --nginx --agree-tos --no-eff-email --email [email protected]

更多细节可以参考 cerbot

  1. 刷新 nginx 配置生效


  1. ngins -s reload
  1. 配置定时任务


  1. sudo certbot renew --dry-run



https://hub.docker.com/r/enwaiax/x-ui


VPS小白 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK