CentOs/Ubuntu搭建上网x-ui

admin
2022-07-17 / 0 评论 / 18 阅读 / 正在检测是否收录...

另一个

#先更新源
yum update
apt update
#启用 BBR TCP 拥塞控制算法
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

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

#安装nginx
apt install nginx
yum install nginx
#安装acme:
curl https://get.acme.sh | sh
#添加软链接:
ln -s  /root/.acme.sh/acme.sh /usr/local/bin/acme.sh
#切换CA机构: 
acme.sh --set-default-ca --server letsencrypt
#申请证书: 
acme.sh  --issue -d 要替换的域名 -k ec-256 --webroot  /var/www/html
#安装证书:
acme.sh --install-cert -d 要替换的域名 --ecc \
--key-file       /etc/x-ui/server.key  \
--fullchain-file /etc/x-ui/server.crt \
--reloadcmd     "systemctl force-reload nginx"

寻找适合的伪装站
http站点优先,个人网盘符合单节点大流量特征
示例关键字: intext:登录 Cloudreve

配置nginx
配置文件路径:/etc/nginx/nginx.conf

# user www-data; #ubuntu下好像用这个
user nginx;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 1024;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    gzip on;

    server {
        listen 443 ssl;
        
        server_name ui.你的域名.shop;  #你的域名
        ssl_certificate       /etc/x-ui/server.crt;  #证书位置
        ssl_certificate_key   /etc/x-ui/server.key; #私钥位置
        
        ssl_session_timeout 1d;
        ssl_session_cache shared:MozSSL:10m;
        ssl_session_tickets off;
        ssl_protocols    TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers off;

        location / {
            proxy_pass http://cloudreve.lee2333.com/; #伪装网址
            proxy_redirect off;
            proxy_ssl_server_name on;
            sub_filter_once off;
            sub_filter "cloudreve.lee2333.com" $server_name;
            proxy_set_header Host "cloudreve.lee2333.com";
            proxy_set_header Referer $http_referer;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header User-Agent $http_user_agent;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header Accept-Encoding "";
            proxy_set_header Accept-Language "zh-CN";
        }


        location /4a872606-be19-path-replace {   #分流路径
            proxy_redirect off;
            proxy_pass http://127.0.0.1:47403; #Xray端口
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            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 /4a872606-be19-path-replace-xui {   #xui路径
            proxy_redirect off;
            proxy_pass http://127.0.0.1:65432;  #xui监听端口
            proxy_http_version 1.1;
            proxy_set_header Host $host;
        }
    }

    server {
        listen 80;
        location /.well-known/ {
               #root /var/www/html;#Ubuntu
               root /usr/share/nginx/html;#centos
            }
        location / {
                rewrite ^(.*)$ https://$host$1 permanent;
            }
    }
}

x-ui创建节点时选择监听127.0.0.1

重新加载nginx
nginx -s reload

更新证书

acme.sh --issue -d xxx.xxx.com -k ec-256 --webroot /usr/share/nginx/html --force
acme.sh --install-cert -d xxx.xxx.com --ecc --key-file /etc/x-ui/server.key --fullchain-file /etc/x-ui/server.crt --reloadcmd "nginx -s reload"
#xxx.xxx.com替换为域名

宝塔面板nginx设置方法

1.新建域名站点,申请SSL证书
2.启用WordPress伪静态
3.配置nginx

    # 入站配置
    location /07f7f {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:12354; #Xray端口
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    # x-ui面板
    location ^~ /07f7f-xui {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:65432/07f7f-xui;  #xui监听端口
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

4.修改x-ui面板监听地址为127.0.0.1(防止端口直接被访问)
修改面板路径/07f7f-xui/
5.重启面板生效

0

评论 (0)

取消