CentOS 7 部署简易 HTTP 代理
需要在一台 CentOS 7 系统的小型 VPS 上安装 HTTP 代理。评估了各种方案,最终选择了 Xray。它占用资源最少,安装配置也最简单。
安装
根据文档,运行下列命令进行安装:
shellbash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
配置
编辑配置文件 /usr/local/etc/xray/config.json,写入如下内容:
json{
"inbounds": [
{
"protocol": "http",
"listen": "0.0.0.0",
"port": 8080,
"tag": "http"
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"domain": ["www.fournoas.com"],
"outboundTag": "direct"
},
{
"type": "field",
"inboundTag": ["http"],
"outboundTag": "block"
}
]
}
}
修改 inbounds[0].port
为代理服务使用的端口,另外将 routing.rules[0].domain
修改为允许代理的域名列表。