阿里云轻量服务器 镜像为Alibaba Cloud Linux 3.21.04
背景
非自动安装openclaw,遇到端口转发的问题,配置nginx,openclaw端口18789,我的域名已经dns解析到服务器的ip上
安装 nginx
sudo rm -f /etc/yum.repos.d/*.repo
sudo vi /etc/yum.repos.d/alinux3.repo
填入内容
[alinux3-os]
name=ALinux 3 OS
baseurl=http://mirrors.aliyun.com/alinux/3/os/x86_64/
enabled=1
gpgcheck=0
[alinux3-updates]
name=ALinux 3 Updates
baseurl=http://mirrors.aliyun.com/alinux/3/updates/x86_64/
enabled=1
gpgcheck=0
安装一些依赖
sudo yum clean all
sudo yum makecache
sudo yum install -y nginx
配置nginx
sudo vi /etc/nginx/conf.d/openclaw.conf
填入内容
server {
listen 80; # 监听 80 端口
server_name 131417.net; # 替换为你的域名 A
location / {
proxy_pass http://127.0.0.1:18789; # 转发到本地 18789
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
}
# 可选:开启 gzip 压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
}
sudo nginx -t
sudo systemctl reload nginx
这样访问 http://openclaw.131417.net/openclaw/?token=自己的token
阿里云服务器Workbench登录不上
阿里云服务器Workbench登录不上,检查安全组网段信息, Workbench使用 100.64.0.0/10 这个网段。
查看服务器iptables安全组信息
sudo iptables -L -n --line-numbers
返回如下
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ts-input all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 ts-forward all -- 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
Chain ts-input (1 references)
num target prot opt source destination
1 ACCEPT all -- 100.120.201.91 0.0.0.0/0
2 RETURN all -- 100.115.92.0/23 0.0.0.0/0
3 DROP all -- 100.64.0.0/10 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:41641
Chain ts-forward (1 references)
num target prot opt source destination
1 MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK xset 0x40000/0xff0000
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 mark match 0x40000/0xff0000
3 DROP all -- 100.64.0.0/10 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
可以看到 两条 DROP 把 Workbench 直接掐死了
解决
① 删除 ts-input 里的 DROP 规则:
sudo iptables -D ts-input 3
② 删除 ts-forward 里的 DROP 规则:
sudo iptables -D ts-forward 3
③ 再确认一次(一定要做):
sudo iptables -L -n --line-numbers
④ 非常重要:保存规则(否则重启会复发):
sudo iptables-save > /etc/sysconfig/iptables
⑤ 不用重启服务器, 回到 阿里云控制台 → Workbench
*** 本文仅是学习中的记录,有错误请指正。 ***
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END




暂无评论内容