EtherDream / jsproxy

An online proxy based on ServiceWorker
MIT License
9.32k stars 3.61k forks source link

【需求】IP白名单【未完成】密码访问【已完成,可查看】 #67

Open chen19870509 opened 5 years ago

chen19870509 commented 5 years ago

openresty 玩不来。。。

chen19870509 commented 5 years ago

也许可以用以下方案 1、ECS 安全组内设置黑白名单#需固定IP 2、防火墙设置黑白名单#需固定IP 3、安装Nginx配置IP、密码访问模块

chen19870509 commented 5 years ago

密码访问已解决 编辑下列文件

/home/jsproxy/server/nginx.conf

http { include log.conf; server { listen 8080; include cert/cert.conf; include api.conf; include www.conf;

auth_basic "Please input password"; #这里是验证时的提示信息

auth_basic_user_file /home/jsproxy/server/nginx/passwd;

}

chen19870509 commented 5 years ago

黑色加粗部分是新增,保存后请务必重启nginx

命令为./run.sh -reload#请用jsproxy账号运行

完整版操作请查看以下链接 https://blog.csdn.net/dream8062/article/details/78416234

chen19870509 commented 5 years ago

第一步 yum -y install httpd-tools 第二步

以下为示例

htpasswd -c /usr/local/src/nginx/passwd userid

userid为你想生成的用户id

passwd为密码文件

/usr/local/src/nginx/为服务器目录

建议操作为

htpasswd -c /home/jsproxy/server/nginx/passwd web

输入后系统将提示输入密码,请自行输入

完成后此时生成了一个账号为web,密码为你自行输入的ID

下一步为开启nginx密码访问 第三步 编辑文件 /home/jsproxy/server/nginx.conf 添加参数 在第一个http内新增以下参数 auth_basic "Please input password"; #这里是验证时的提示信息 auth_basic_user_file /home/jsproxy/server/nginx/passwd; 第四步 重启nginx 以jsproxy账号登入,运行命令 ./run.sh -reload

打开网页就提示密码了

chen19870509 commented 5 years ago

nginx.zip 参照

chen19870509 commented 5 years ago

遇401提示按Ctrl+F5,强制刷新即可

EtherDream commented 5 years ago

密码访问用 auth_basic 有问题的,只能限制静态资源服务,不能限制接口服务。当然简单的场合使用没问题。

这个功能还在设计中,目前在考虑用 session 机制实现。

chen19870509 commented 5 years ago

等不及的用户可以用上面的 方案测试 一个人用还行