muzea / portfwd

A low performance port forwarding implementation
https://muzea.github.io/portfwd
20 stars 4 forks source link

建议config.json里添加访问密码,如果密码不对,则禁止api访问 #7

Open j0hnnie opened 5 years ago

j0hnnie commented 5 years ago

例如在 config.json 中 加入一个 secret 字段

[root@xxx portfwd]# cat config.json 
{
    "proxy": {
    "5000": "47.xxx.xxx.xxx:5000",
    "5001/8000": "47.xxx.xxx.xxx:5001"
    },
    "APIPort": ":3001",
    "secret": "这里是访问密码"
}

如果secret密码错了,则api请求报错,因为我发现我portfwd部署到线上,经常受到僵尸网络和爬虫的骚扰

j0hnnie commented 5 years ago

我去,貌似搞复杂了config.json 加secret 的话在每个api请求的时候 都需要带上这个secret了。

例如: http://portfwd.xxx:3001/proxy/5000?secret=123

或者API请求参数第一个永远都是密码??? http://portfwd.xxx:3001/密码/proxy/5000?secret=123

muzea commented 5 years ago

这个我建议用一个nginx或者caddy做反代,用http basic authentication或者自己定义一个权限校验头