Nginx 配置转发到 TTYD 7681 端口
假设 ttyd 已经在服务器上安装并运行,以下是配置 nginx 转发到 ttyd 的 7681 端口的步骤:
-
打开 nginx 的配置文件,通常在
/etc/nginx/nginx.conf或者/etc/nginx/conf.d/default.conf中。 -
在 http 部分中添加以下配置:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:7681/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
}
- 保存配置文件并重启 nginx 服务。
现在,当用户访问 yourdomain.com 时,nginx 会将请求转发到 ttyd 的 7681 端口上。注意,如果你使用的是 HTTPS,需要将 listen 80 改为 listen 443,并添加 SSL 证书相关的配置。
原文地址: https://www.cveoy.top/t/topic/fVaE 著作权归作者所有。请勿转载和采集!