owenyoung 13小时前
在Debian系统中安装 Gost
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文详细介绍了在Debian系统上,如何使用Gost代理工具进行HTTP、HTTPS、SOCKS5等协议的转发,并结合acme.sh工具实现HTTPS证书的自动申请与续期。文章从下载和安装Gost开始,展示了如何使用Systemctl服务管理Gost进程。同时,重点讲解了如何利用Cloudflare的API来自动签发和续期Let's Encrypt证书,并将其安全地安装到Gost目录中,以启用HTTPS连接。最后,提供了Gost的启动脚本配置、日志查看方法以及Clash和Gost中转节点的客户端配置示例,帮助用户构建安全可靠的代理转发服务。

📦 Gost是一款灵活的代理转发工具,支持HTTP、HTTPS、SOCKS5等多种协议,并可配置反嗅探策略,为用户提供多样的网络代理解决方案。

🔒 使用acme.sh工具配合Cloudflare的API,可以方便地为Gost代理申请并自动续期HTTPS证书,确保通信的安全性,并简化了证书管理的流程。

⚙️ 通过Systemctl服务化配置,可以实现Gost代理的后台运行、开机自启以及异常情况下的自动重启,提高了代理服务的稳定性和可用性。

📝 文章提供了详细的Gost启动脚本编写和客户端配置指导,包括Clash和Gost中转节点,使用户能够根据自身需求灵活配置代理转发和连接方式。

🌐 成功配置HTTPS证书后,Gost代理可以更安全地进行数据传输,无论是作为直接代理还是中转节点,都能为用户提供更加私密和安全的网络访问体验。

Gost 是一个灵活的代理转发工具,可以转发 HTTP、HTTPS、SOCKS5 等协议,可以配置反嗅探策略等等。

本文记录在 Debian 上使用 Systemctl 配置 Gost 代理,以及使用 acme.sh 配置 https 证书。

1. 下载并解压最新的 Gost 压缩包🔗

Gost Release找到最新版本的压缩包,比如 我的服务器系统是 Debian,amd64 架构,所以对应的是https://github.com/ginuerzh/gost/releases/download/v2.11.2/gost-linux-amd64-2.11.2.gz

# create gost directorymkdir gost# download to current directorywget https://github.com/ginuerzh/gost/releases/download/v2.11.2/gost-linux-amd64-2.11.2.gz# unzipgzip -d gost-linux-amd64-2.11.2.gzmv gost-linux-amd64-2.11.2.gz gost# Add execute permissionchmod +x gost

2. 申请 https 证书并自动续期🔗

我使用acme.sh来管理证书,并且使用 Cloudflare 作为 DNS 管理,因为 Cloudflare 提供了 API 来验证域名所属权限,这样签发证书更方便。

    下载 acme 工具:
wget -O - https://get.acme.sh | sh -s email=my@example.com

    把域名在 Cloudflare 添加解析,解析到你的服务器 IP

    在某个域名的 dashboard 面板右侧找到 Account ID, 记录下备用。

    进入https://dash.cloudflare.com/profile/api-tokens,生成一个 API Token,选择Edit Zone 模版,Zone Resources 选择 All Zones,生成,

把以下的信息保存到 ~/.bashrc

export CF_Token="sdfsdfsdfljlbjkljlkjsdfoiwje"export CF_Account_ID="xxxxxxxxxxxxx"

使之生效:

source ~/.bashrc

如果还有什么不清楚的,可以参考文档: https://github.com/acmesh-official/acme.sh/wiki/dnsapi

签发证书🔗

修改 example.com 为你的域名

运行 acme.sh --issue --dns dns_cf -d example.com

Note: 默认的签发机构是Zerossl, 也可以使用 letsencrypt , acme.sh --issue --dns dns_cf -d example.com --server letsencrypt

运行之后他就会自动续期该域名,你可以检查 crontab 任务是否添加成功: crontab -e

3. 使用 Systemctl 启动🔗

sudo vim /etc/systemd/system/gost.service

写入以下文件:

修改 /home/green/gost/ 为你的 gost 文件夹

[Unit]Description=GostAfter=syslog.target network.target[Service]WorkingDirectory=/home/green/gost/User=greenGroup=adminUMask=0002Restart=on-failureRestartSec=5Type=simpleExecStart=/home/green/gost/start.shKillSignal=SIGINTTimeoutStopSec=20SyslogIdentifier=gost[Install]WantedBy=multi-user.target

使之生效:

sudo systemctl daemon-reloadsudo systemctl enable gost

4. 安装证书🔗

安装证书到 gost 目录🔗

修改 ~/gost/为你的文件夹, example.com 为你的域名

acme.sh --install-cert -d example.com \--cert-file ~/gost/cert.pem  \--key-file ~/gost/key.pem  \--ca-file ~/gost/ca.pem \--reloadcmd "sudo systemctl restart gost"

5. 启动服务🔗

Gost 的命令还挺长的,所以可以写的简单的脚本,以后启动方便点:

vim start.sh
#!/bin/bash# 下面的3个参数需要改成你的USER="xxxx"PASS="xxxxxxxx"PORT=8443BIND_IP=0.0.0.0sudo ./gost \    -L "http2://${USER}:${PASS}@${BIND_IP}:${PORT}?probe_resist=web:www.baidu.com:443&knock=example.com"

添加执行权限

chmod +x ./start.sh

6. 查看日志🔗

# 查看状态sudo systemctl status gost# 查看日志sudo journalctl -u gost -f

7. 客户端配置🔗

参见这里

7.1 clash 配置参考🔗

- name: h8443  password: xxxxxxxx  port: 8443  server: example.com  tls: true  skip-cert-verify: true  type: http  username: xxxx

7.2 Gost 中转节点🔗

在中转节点安装 gost,步骤同上

cd ~/gostvim config.json
{  "ServeNodes": ["socks5://username:pass@0.0.0.0:1080"],  "ChainNodes": ["https://username:pass@example:443"]}
vim start.sh
#!/bin/bash# 下面的3个参数需要改成你的USER="xxxx"PASS="xxxxxxxx"DOMAIN="xxxx.com"PORT=1080TARGET_PORT=8443BIND_IP=0.0.0.0sudo ./gost \    -L "socks5://${USER}:${PASS}@${BIND_IP}:${PORT}" -F "https://${USER}:${PASS}@${DOMAIN}:${TARGET_PORT}"

添加执行权限

chmod +x ./start.sh

按照如上步骤 3,添加 systemctl 服务

参考🔗

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Gost 代理转发 HTTPS acme.sh Debian Systemctl
相关文章