Skip to content

Hysteria 2 部署教程

安装 Hysteria

安装或更新

sh
bash <(curl -fsSL https://get.hy2.sh/)

卸载

sh
bash <(curl -fsSL https://get.hy2.sh/) --remove

配置服务端

生成自签证书

sh
openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -subj "/CN=bing.com" -days 36500 && sudo chown hysteria /etc/hysteria/server.key && sudo chown hysteria /etc/hysteria/server.crt

基本配置

yaml
listen: :8443 #监听端口

tls:
  cert: /etc/hysteria/server.crt
  key: /etc/hysteria/server.key

auth:
  type: password
  password: <Password> # 连接密码
  
masquerade:
  type: proxy
  proxy:
    url: https://bing.com
    rewriteHost: true
    
ignoreClientBandwidth: false # 启用后,服务器将忽略客户端设置的任何带宽,永远使用传统的拥塞控制算法(目前为 BBR)

出站

为了实现 IPv4 优先与分流,我们还可以单独设置出站,目前 Hysteria 2 只支持 direct socks5 http 出站,其中第一个出站为默认出站,因此建议将 direct 放在第一个

direct 出站中,可以通过 mode 选项来指定 IPv4 与 IPv6 的优先级

提示

直连的 IPv4 和 IPv6 优先级由 mode 设置决定,与系统设置的优先级无关

yaml
outbounds:
  - name: DIRECT
    type: direct
    direct:
      mode: 46
  - name: WARP
    type: socks5
    socks5:
      addr: 127.0.0.1:40000

ACL

ACL 类似路由规则,按照 outbound(address) 的格式就可以实现分流到指定出站

yaml
acl:
  inline: 
    - warp(geosite:reddit)
    - reject(geoip:cn)

配置客户端

yaml
- name: Hysteria 2
  type: hysteria2
  server: <Server IP>
  port: 8443
  up: 30 # brutal 速率控制,不填写则使用 BBR
  down: 100 # brutal 速率控制,不填写则使用 BBR
  password: <Password> # 服务端配置的密码
  skip-cert-verify: true # 使用自签证书需要为 true

常用命令

  • 设置开机启动 systemctl enable hysteria-server
  • 启动 Hysteria 2 systemctl start hysteria-server
  • 关闭 Hysteria 2 systemctl stop hysteria-server
  • 重启 Hysteria 2 systemctl restart hysteria-server
  • 检查运行状况 systemctl status hysteria-server
关注微信公众号
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0

预览:

评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3