Hysteria2¶
一、参考文档¶
二、直接安装¶
Linux 服务端部署脚本 提供了一个 bash 脚本,可以在常见的 Linux 发行版上自动下载最新版本的 Hysteria 并配置 systemd 服务。 安装或升级到最新版本:
bash <(curl -fsSL https://get.hy2.sh/)
执行完脚本之后去/etc/hysteria进行配置,修改config.yaml,相关参数可以官方文档查看
listen: :443
tls:
cert: /etc/hysteria/xxxx.cc.pem
key: /etc/hysteria/xxxx.key
auth:
type: password
password: yourpassword
# 伪装
masquerade:
type: proxy
proxy:
url: https://news.ycombinator.com/
rewriteHost: true
# DNS
resolver:
type: udp
tcp:
addr: 8.8.8.8:53
timeout: 4s
udp:
addr: 8.8.4.4:53
timeout: 4s
tls:
addr: 1.1.1.1:853
timeout: 10s
sni: cloudflare-dns.com
insecure: false
https:
addr: 8.8.8.8:443
timeout: 10s
启动服务
# 查找
sudo find / -type f -name "*hysteria*"
# 后台运行
nohup /usr/local/bin/hysteria server > /etc/hysteria/hysteria.log 2>&1 &
# 重启
nohup /usr/local/bin/hysteria server restart > /etc/hysteria/hysteria.log 2>&1 &
三、Docker安装¶
创建docker-compose.yaml配置文件,示例,创建/etc/hysteria/hysteria.yaml文件、/etc/hysteria/acme 文件夹,acme用于存放证书信息
version: "3.9"
services:
hysteria:
image: tobyxdd/hysteria
container_name: hysteria
restart: always
network_mode: "host"
volumes:
- /etc/hysteria/acme:/acme
- /etc/hysteria/hysteria.yaml:/etc/hysteria.yaml
command: ["server", "-c", "/etc/hysteria.yaml"]
volumes:
acme:
hysteria.yaml 内容参考上面的config.yaml,要注意hysteria.yaml里面的路径要用容器里面的路径,比如证书cert: /acme/xxxx.cc.pem
启动
# 后台启动
docker compose up -d
# 停止
docker compose down
四、客戶端¶
由 v2rayN 提供 HTTP SOCKS5 代理,由 v2rayN 提供路由规则¶
1.下载Windows客户端程序hysteria-windows-amd64.exe,重命名为hysteria.exe,复制到v2rayN\bin\hysteria文件夹。
2.下载客户端配置config_client.yaml,修改chika.example.com为证书中包含的域名,修改10.0.0.1为VPS的IP。 参考:
server: "10.0.0.1:443"
auth: yourpasswd
tls:
sni: test.example.com
insecure: true
pinSHA256: BA:88:45:17:A1...
bandwidth:
up: 30 mbps
down: 300 mbps
socks5:
listen: 127.0.0.1:50000
3.v2rayN:服务器 ——> 添加自定义配置服务器 ——> 浏览 ——> 选择客户端配置 ——> Core类型 hysteria ——> Socks端口 50000
五、注意¶
如果有使用防火墙的,要开启listen配置的端口号
docker之所以不用映射端口号,是因为使用了host模式,无需映射端口