X-UI

X-UI安装

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

X-UI魔改版 – GitHub

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

X-UI安装自签证书(适用于Ubuntu)

apt install -y cron
apt install -y socat
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --register-account -m 邮箱地址
~/.acme.sh/acme.sh --issue -d 域名地址 --standalone
~/.acme.sh/acme.sh --installcert -d 域名地址 --key-file /root/private.key --fullchain-file /root/cert.crt

~/.acme.sh/acme.sh --upgrade 
~/.acme.sh/acme.sh --upgrade --auto-upgrade

确认证书的开始日期以及过期日期

openssl x509 -in /root/cert.crt -noout -dates

强制手动更新所有证书

~/.acme.sh/acme.sh --renew-all --force

# 手动设置自动续签(可选,如果安装时没有自动添加 cron 作业)
# 添加 cron 作业以自动续签证书

~/.acme.sh/acme.sh --install-cronjob

# 你可以手动运行以下命令来测试续签

~/.acme.sh/acme.sh --renew -d 你的域名 --force

检查 cron 任务是否正确安装

crontab -l

它应该显示类似以下的内容:

0 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null

这个任务会每天凌晨运行

查看cron服务的运行状态,启动或者重启命令

systemctl status cron
systemctl start cron
systemctl restart cron

强制用cron手动续签证书

"/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" --force

X-UI面板定时重启

要每天自动重启x-ui面板,可以使用cron任务来实现。以下是具体步骤:

  1. 打开终端,输入以下命令来编辑crontab,目录在/var/spool/cron/crontabs
crontab -e

2、加入下面的命令行

0 4 * * * systemctl restart x-ui

这个命令会在每天凌晨4点重启x-ui服务。如果您想在不同时间重启,可以调整前两个数字。例如:

  • 0 0 * * * 表示每天午夜重启
  • 0 12 * * * 表示每天中午12点重启

然后看是否生效

crontab -l

或者也可以使用下面的命令行:

0 4 * * * /usr/local/x-ui/x-ui restart

如何打不开文件夹,输入以下命令即可

chmod 777 /root

X-UI转发全部的流量1

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "tag": "outbound_to_B",
      "protocol": "socks",
      "settings": {
        "servers": [
          {
            "address": "域名orIP地址",
            "port": 端口号,
            "users": [
              {
                "user": "用户名",
                "pass": "密码"
              }
            ]
          }
        ]
      }
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    }
  ],
  "policy": {
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "type": "field",
        "outboundTag": "outbound_to_B",
        "network": "tcp,udp"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      }
    ]
  },
  "stats": {}
}

X-UI转发全部的流量2

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "socks",
      "settings": {
        "servers": [
          {
            "address": "socks代理ip或者域名",
            "port": 端口号,
            "users": [
              {
                "user": "用户名",
                "pass": "密码"
              }
            ]
          }
        ]
      },
      "tag": "proxy"
    },
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "direct",
        "type": "field"
      },
      {
        "type": "field",
        "network": "tcp,udp",
        "outboundTag": "proxy"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "stats": {}
}

X-UI如何分别转发Netflix和DisneyPlus的流量到其它VPS

把下面的域名和端口分别替代掉即可

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "tag": "NETFLIX",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "奈飞VPS", 
                    "port": 端口号, 
                    "users": [{
                               "user": "用户名",
                                "pass": "密码",
                                "level": 0
                          }]
                }
            ]
        }
    },
    {
      "tag": "DISNEY",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "迪士尼VPS", 
                    "port": 端口号, 
                    "users": [{
                               "user": "用户名",
                                "pass": "密码",
                                "level": 0
                          }]
                }
            ]
        }
    }
  ],
  "policy": {
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      },
      {
        "type": "field",
        "outboundTag": "NETFLIX",
        "domain": ["geosite:netflix"]},
      {
        "type": "field",
        "outboundTag": "DISNEY",
        "domain": ["geosite:disney"] 
      }
    ]
  },
  "stats": {}
}

X-UI单独中转DisneyPlus或者Netflix的流量

DisneyPlus

修改X-UI的配置文件如下:

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "tag": "DISNEY",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "可以看DP的VPS", 
                    "port": 端口号, 
                    "users": [{
           "user": "用户名",
            "pass": "密码",
            "level": 0
      }]
                }
            ]
        }
    }
  ],
  "policy": {
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      },
      {
        "type": "field",
        "outboundTag": "DISNEY",
        "domain": ["geosite:disney"] 
      }
    ]
  },
  "stats": {}
}

Netflix

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "tag": "NETFLIX",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "可以看Netflix的VPS", 
                    "port": 端口号, 
                    "users": [{
           "user": "用户名",
            "pass": "密码",
            "level": 0
      }]
                }
            ]
        }
    }
  ],
  "policy": {
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      },
      {
        "type": "field",
        "outboundTag": "NETFLIX",
        "domain": ["geosite:netflix"] 
      }
    ]
  },
  "stats": {}
}

X-UI配合cloud flare自签证书会出现一个问题,就是只能一个上网,后开的账户无法上网,没啥解决方式,换其他SSL证书即可解决。

这里再贴一个x-ui的配置文件,包括sock转Disney+,Netflix以及ChatGPT

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "tag": "NETFLIX",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "netflix.zhec.org", 
                    "port": 端口号, 
                    "users": [{
                               "user": "用户名",
                                "pass": "密码",
                                "level": 0
                          }]
                }
            ]
        }
    },
    {
      "tag": "DISNEY",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "disneyplus.zhec.org", 
                    "port": 端口号, 
                    "users": [{
                               "user": "用户名",
                                "pass": "密码",
                                "level": 0
                          }]
                }
            ]
        }
    },
    {
      "tag": "CHATGPT",
      "sendThrough": "0.0.0.0",
      "protocol": "socks",
      "settings": {
            "servers": [
                {
                    "address": "chatgpt.zhec.org", 
                    "port": 端口号, 
                    "users": [{
                               "user": "用户名",
                                "pass": "密码",
                                "level": 0
                          }]
                }
            ]
        }
    }
  ],
  "policy": {
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked",
        "type": "field"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      },
      {
        "type": "field",
        "outboundTag": "NETFLIX",
        "domain": ["geosite:netflix"]},
      {
        "type": "field",
        "outboundTag": "DISNEY",
        "domain": ["geosite:disney"] 
      },
      {
        "type": "field",
        "outboundTag": "CHATGPT",
        "domain": ["geosite:openai"] 
      }
    ]
  },
  "stats": {}
}

X-UI安装在腾讯云或者阿里云上,用socks来中转的配置文件

{
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "protocol": "socks",
      "settings": {
        "servers": [
          {
            "address": "138.2.277.90",
            "port": 19092,
            "users": [
              {
                "user": "ZcIbeCplEF",
                "pass": "ED4W4fwG7S"
              }
            ]
          }
        ]
      },
      "tag": "socks-out"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "rules": [
      {
        "type": "field",
        "inboundTag": ["api"],
        "outboundTag": "socks-out"
      },
      {
        "type": "field",
        "outboundTag": "socks-out",
        "domain": ["geosite:geolocation-!cn"]
      },
      {
        "type": "field",
        "outboundTag": "socks-out",
        "ip": ["geoip:!private"]
      }
    ]
  },
  "stats": {}
}
Share

You may also like...

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注