魔法教学

VLESS配置

概述

步骤

  1. 为网站添加SSL证书,并勾选强制HTTPS
  2. 修改网站配置文件:点击配置文件,找到#SSL-END并在其下面添加如下代码:
1
2
3
4
5
6
7
8
9
10
11
//cs是你自己ws的path,可以修改
location /cs
{
proxy_pass http://127.0.0.1:你的端口号,端口号自定
proxy_redirect off;
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;
}
  1. 开启防火墙端口或者直接关闭防火墙

  2. 安装v2ray最新官方脚本

1
2
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh
  1. 安装和更新V2Ray
1
bash install-release.sh
  1. 安装geoip.dat和geosite.dat
1
bash install-dat-release.sh
  1. 生成UUID:https://1024tools.com/uuid

  2. 进入 /usr/local/etc/v2ray/目录,编辑config.json文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbounds": [
{
"port":你的端口,
"listen": "127.0.0.1",
"tag": "VLESS-in",
"protocol": "VLESS",
"settings": {
"clients": [
{
"id":"你的 UUID",
"alterId": 0
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path":"/cs" //若没有修改过配置文件中的pach,这里就是cs
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": { },
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": { },
"tag": "blocked"
}
],
"dns": {
"servers": [
"https+local://1.1.1.1/dns-query",
"1.1.1.1",
"1.0.0.1",
"8.8.8.8",
"8.8.4.4",
"localhost"
]
},
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"inboundTag": [
"VLESS-in"
],
"outboundTag": "direct"
}
]
}
}
  1. 设置开机启动
1
2
systemctl enable v2ray
systemctl start v2ray

Trojan-Go配置

步骤

  1. 为网站添加SSL证书,并勾选强制HTTPS

  2. 下载文件

  3. 修改server.json

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    {
    "run_type": "server",
    "local_addr": "0.0.0.0",
    "local_port": 连接Trojan的端口,
    "remote_addr": "网站域名",
    "remote_port": Web端口,
    "password": [
    "密码"
    ],
    "ssl": {
    "cert": "/www/server/panel/vhost/cert/网站域名/fullchain.pem",
    "key": "/www/server/panel/vhost/cert/网站域名/privkey.pem",
    "sni": "网站域名",
    "fallback_addr": "网站域名",
    "fallback_port": Web端口
    },
    "router": {
    "enabled": true,
    "block": [
    "geoip:private"
    ],
    "geoip": "/opt/trojan-go/geoip.dat",
    "geosite": "/opt/trojan-go/geosite.dat"
    }
    }
  4. 设置服务

    1
    vim /etc/systemd/system/trojan-go.service
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    [Unit]
    Description=Trojan-Go
    After=network.target nss-lookup.target
    Wants=network-online.target

    [Service]
    Type=simple
    User=root
    ExecStart=/opt/trojan-go/trojan-go -config /opt/trojan-go/server.json
    Restart=on-failure
    RestartSec=5

    [Install]
    WantedBy=multi-user.target
  5. 设置开机启动

    1
    2
    systemctl enable trojan-go.service
    systemctl start trojan-go.service