搭建hysteria2 服务端

作者:matrix 发布时间:2024 年 1 月 31 日 分类:零零星星

服务器配置

配置文件的目录
/root/hysteria

自签证书key crt生成

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

# sudo chown hysteria /root/hysteria/server.key
# sudo chown hysteria /root/hysteria/server.crt

新建hysteria2.yaml文件


listen: :443 #监听端口 #使用CA证书 #acme: # domains: # - hhtjim.com #你的域名,需要先解析到服务器ip # email: test@hhtjim.com #使用自签证书 tls: cert: /app/server.crt key: /app/server.key auth: type: password password: 999999 #设置认证密码 masquerade: type: proxy proxy: url: https://www.baidu.com #伪装网址 rewriteHost: true

最终需要的三个文件

hysteria2.yaml
server.crt
server.key

启动服务

docker run -v /root/hysteria:/app/ --net=host --rm -it tobyxdd/hysteria server  -c /app/hysteria2.yaml

客户端使用

新建配置文件hysteria2-client.yaml


# 服务器信息及端口 server: server.hhtjim.com:443 auth: 999999 # 根据本地带宽设置上下行 bandwidth: up: 20 mbps down: 300 mbps tls: insecure: true #使用自签时需要改成true socks5: listen: 127.0.0.1:1084 http: listen: 127.0.0.1:8084

启动


docker run -v $(pwd)/hysteria2-client.yaml:/app/hysteria2.yaml --net=host --name=hysteria2-client -d tobyxdd/hysteria client -c /app/hysteria2.yaml

参考:
https://vpsxb.net/5008/

https://raw.githubusercontent.com/chika0801/hysteria-install/main/config_server.yaml

https://bulianglin.com/archives/hysteria2.html

部署Docker版Hysteria服务端