Xray 配置记录
在项目实施过程中,经常会遇到服务器没有外网,需要经由跳板机作为中转使用的情况,因此有个代理服务器就很有必要了。
Xray 更新比较快,配置时不时可能就要对应更新,因此还是记录一下,方便部署时之间使用,有变动时也同步进行更新。
零、架构
Client
│
VLESS + XHTTP(stream-up)
TLS(h2)
│
▼
OpenResty :443
TLS terminate
grpc_pass
│
▼
127.0.0.1:10000
Xray
VLESS + XHTTP
security:noneXray版本: ghcr.io/xtls/xray-core:26.6.27
一、Nginx 配置
location /sgip {
grpc_set_header Host $host;
grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
grpc_set_header X-Real-IP $remote_addr;
grpc_read_timeout 600s;
grpc_send_timeout 600s;
# 替换为实际的IP和端口
grpc_pass grpc://172.17.0.2:1090;
}二、服务端
05_inbounds.json
uuid可以使用xray uuid命令来进行生成
{
"inbounds": [
{
"listen": "0.0.0.0",
"port": 1090,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "bcd85299-ac78-48b8-ae2e-37f29ddbc588"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "xhttp",
"security": "none",
"xhttpSettings": {
"path": "/xhttp",
"mode": "stream-up"
}
}
}
]
}06_outbounds.json
{
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
}
]
}三、客户端
{
"inbounds": [
{
"listen": "0.0.0.0",
"port": 1080,
"protocol": "http"
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "example.com",
"port": 443,
"users": [
{
"id": "bcd85299-ac78-48b8-ae2e-37f29ddbc588",
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "xhttp",
"security": "tls",
"tlsSettings": {
"serverName": "example.com",
"alpn": [
"h2"
]
},
"xhttpSettings": {
"host": "example.com",
"path": "/xhttp",
"mode": "stream-up"
}
}
}
]
} 
