海运的博客

Nginx设置目录密码认证/限制特定IP访问

发布时间:April 8, 2012 // 分类:Nginx,网络安全 // No Comments

网络安全无处不在,使用Nginx为您的网站后台加把锁吧。
验证界面如:
2012-04-08_071422.png
1.Nginx兼容于Apache下htpasswd生成的密钥,不过Nginx下无此工具,可以使用crypt生成密码。

perl -e 'print crypt($ARGV[0], "pwdsalt")' password ;echo ""#password请更改为您的密码

用php生成sha密码,不建议:

$user = 'test';
$pass = 'test';
$sha1 = base64_encode(sha1($pass, true));
echo $user.':{SHA}'.$sha1;

使用openssl生成sha512crypt密码,建议使用。

echo 123456|openssl passwd -6 -in - 

结果即加密后的密码,新建密钥配置谁的将用户密码以以下方式添加。

user:passwd

编辑Nginx配置文件

location ^~ /admin/ {        #特定目录
location ~ .*\.(php|php5)?$ {
allow 192.168.1.16; #允许IP
deny all; #拒绝所有
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
auth_basic "Login";
auth_basic_user_file /passwdfile;
}

添加ip白名单跳过验证:

satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Login";
auth_basic_user_file /passwdfile;

Apache服务器安全设置

发布时间:April 7, 2012 // 分类:Apache,网络安全 // No Comments

Apache是世界上占用率最大的web服务器软件,以安装、稳定而著称,默认安装后有一些限制较为宽松,可进一步设置加固其安全。
1.隐藏版本信息:

ServerSignature off #不输出任何页脚信息
ServerTokens prod #不输出apache版本信息

2.以低权限用户运行:

User nobody
Group nobody

3.网站目录设定:

<Directory "/var/www/html">
#Options Indexes FollowSymLinks #取消目录浏览,链接到其它目录
AllowOverride None  #禁止htaccess
php_admin_value open_basedir /var/www/html/ #限制活动目录,防止跨站,多个目录以:相隔
Order allow,deny
Allow from all
</Directory>

4.隐藏php版本,编辑php配置文件php.ini,添加或修改:

expose_php Off

此内容被密码保护

发布时间:April 7, 2012 // 分类:VPN // 12 Comments

请输入密码访问

Nginx图片/文件防盗链配置

发布时间:April 7, 2012 // 分类:Nginx // No Comments

Nginx可根据浏览器请求的Referer防盗链,限制非本站的页面链接请求,更严格的限制可使用防盗链模块nginx-accesskey,可防止迅雷盗链。
编辑Nginx配置文件,在Server段加入以下内容:

location ~* \.(jpg|gif|png)$ {      #限制的文件类型                                                                                                
valid_referers none blocked *.www.haiyun.me www.haiyun.me; #定义允许的域名
if ($invalid_referer) {   #如果请求非允许
#rewrite ^/ https://www.haiyun.me/error.png; #定向到指定图片
       return 403; #返回403
    }
  }

Centos/Linux下忘记Mysql数据库root密码解决方法

发布时间:April 6, 2012 // 分类:Linux基础,数据库 // No Comments

Windows下请参考windows下重置mysql root密码
1.停止mysql服务

/etc/init.d/mysql stop

2.以skip-grant-tables参数启动mysql

/usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

3.以空密码方式登录mysql

mysql -u root

4.重置root账号密码

update mysql.user set password=PASSWORD('newpassword') where User='root';

5.刷新权限表

flush privileges;
````
6.退出mysq并重启

/etc/init.d/mysql restart

分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
归档