• NPM 与 XUI 共存!Nginx Proxy Manager 搭配 X-UI 实现 Vless+WS+TLS 教程!


    之前分享过搭建可以与宝塔共存的一个 “魔法” 服务器状态监控应用 ——xui,支持 Vmess+WS+TLS。

    最近 Docker 视频出的比较多,前阵子又出现了宝塔国内版存在隐私泄露的问题,很多小伙伴其实都不用宝塔了,那么,在我们现在装了 Nginx Proxy Manager(NPM)的环境下,80 和 443 端口都转由 NPM 来管理了,可以让 XUI 和 NPM 共存吗?如何用 NPM 来反代 XUI 呢?今天我们就来折腾一下!

    1. 搭建环境

    2. 搭建视频

    YouTube:https://youtu.be/aYC4BTzbw8c

    3. 搭建方式

    3.1 服务器初始设置

    服务器初始设置,参考

    新买了一台服务器 “必须” 要做的 6 件小事

    【Docker 系列】不用宝塔面板,小白一样可以玩转 VPS 服务器!

    3.2 下载 xui

    新版(支持功能更多):

    BASH

    bash <(curl -Ls https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh)
    

    GitHub 地址:GitHub - FranzKafkaYu/x-ui: Lightweight Xray panel with multi-protocol and multi-user on the same port,supports English language and Telegram bot. Easy to use and easy to manage.

    旧版:

    BASH

    bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
    

    根据提示设置端口信息用户名密码

    3.3 登陆 xui 面板并配置

    image-20220519173838476

    切换最新版本:

    image-20220519173900021

    修改面板路径:

    image-20220519173916580

    记得保存配置

    添加入站列表:

    image-20220519174016372

    如果配置,只需要修改 4 个地方:

    image-20220519174141370

    点击添加,之后点击重启面板

    image-20220519174237766

    3.4 NPM 配置

    2022-12-15 更新简单方法

    无需手动进入目录修改,只需要在面版即可操作!

    选择任意一个 NPM 代理上,分别在下面两个位置填入下面两个部分内容:

    image-20221215182225687

    代替了旧方法中的:

    NGINX

    location ^~ /fuckgfw {              #fuckgfw换成你前面设置的面板的url根路径
        proxy_pass http://158.101.3.171:54331/fuckgfw;  # IP填服务器IP,这边不能填127.0.0.1,因为是在容器里,54331换成你xui面板的端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    

    image-20221215182244204

    NGINX

    location /plogger {                 # plogger填你前面设置的ws的路径
            proxy_redirect off;
            proxy_pass http://158.101.3.171:13997;    # IP填服务器IP,这边不能填127.0.0.1,因为是在容器里,13997换成你入站规则那边的IP
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;
            proxy_read_timeout 300s;
            # Show realip in v2ray access.log
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    

    保存即可!


    以下为旧方法,不建议采用

    登陆服务器,来到 NPM 的安装路径下(这边假设大家都是用【Docker 系列】一个反向代理神器 ——Nginx Proxy Manager 这篇文章的方法搭建的):

    BASH

    cd /root/data/docker_data/npm
    

    查看当前文件:

    BASH

    ls -al
    

    image-20220519174804818

    我们的文件都在 data 目录下,一层一层找,找到我们的 Nginx 配置文件。

    BASH

    cd data/nginx/proxy_host
    

    image-20220519175123930

    可以看到两个文件(如果你 NPM 反代多的话,可能有很多个)

    这边比较讨厌,是数字命名的,其实我们随便选一个也行。

    image-20220519175343318

    image-20220519175542303


    以上为旧方法,不建议采用。

    在上述位置加入以下内容:

    NGINX

    location ^~ /fuckgfw {              #fuckgfw换成你前面设置的面板的url根路径
        proxy_pass http://158.101.3.171:54331/fuckgfw;  # IP填服务器IP,这边不能填127.0.0.1,因为是在容器里,54331换成你xui面板的端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /plogger {                 # plogger填你前面设置的ws的路径
            proxy_redirect off;
            proxy_pass http://158.101.3.171:13997;    # IP填服务器IP,这边不能填127.0.0.1,因为是在容器里,13997换成你入站规则那边的IP
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;
            proxy_read_timeout 300s;
            # Show realip in v2ray access.log
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    

    保存后,重启一下 NPM。

    BASH

    cd /root/data/docker_data/npm    # 来到docker-compose.yml所在的文件夹下
    
    docker-compose restart  # 重启
    

    4. 客户端连接

    以小火煎为例子,其他客户端类似:

    点击打开二维码:

    image-20220519180233466

    image-20220519180412072

    image-20220519180510046

    image-20220519180554086

    完整配置参考:

    image-20220519180630504

    image-20220519180644375

    启动节点:

    image-20220519180728131

    浏览器输入 https://ip.skk.moe/

    image-20220519180831650

    搞定!

    5. 注意事项(重要)

    由于我们是直接修改的配置文件,所以,在反代的这个站点,不用轻易在 NPM 后台面板上修改原来的配置(比如打开,然后点确定),这样会破坏掉我们这边写的 Nginx 配置文件,导致节点无法正常使用。

  • 相关阅读:
    智慧校园烟火识别及预警解决方案,保障校园消防安全
    蓄电池与超级电容混合储能并网逆变系统Simulink仿真
    玩机搞机-----安卓全机型刷机卡fastboot模式解决方法与故障解析
    成绩统计-蓝桥杯
    小兴教你做平衡小车-stm32程序开发(PWM)
    Web UI自动化测试框架
    C语言实现的多项式合并运算系统
    物联网浏览器(IoTBrowser)-使用深度学习开发防浸水远程报警
    16.力扣c++刷题-->找出字符串中第一个匹配的子串
    滚动条不占位置
  • 原文地址:https://blog.csdn.net/u012995136/article/details/134485643