[原创] Nginx 添加授权访问 使用 httpd-tools
2017-03-28 17:27
405 查看
安装 nginx
yum install -y nginx
安装 iptables iptables-services
使用 iptables-services 管理配置文件yum install -y iptables iptables-services
配置 iptables
# vi /etc/sysconfig/iptable # 默认有22端口, 复制一行, 改为 nginx 端口即可. -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
启动 iptables
service iptables start
安装 httpd-tools
# 生成密码 yum install -y httpd-tools
生成密码文件
htpasswd /etc/nginx/httpdwd nginx_user
配置 nginx
# vi /etc/nginx/nginx.conf # 在 配置中添加 auth_basic 和 auth_bashc_user_file 即可 server { listen 80 default_server; listen [::]:80 default_server; server_name _; client_max_body_size 10K; root /usr/share/nginx/html; # 在这里添加授权配置 auth_basic "Username and Password are required"; auth_basic_user_file /etc/nginx/httpdwd; # ... ... }
启动 nginx
service nginx start
完
相关文章推荐
- [原创]Java中,使用JDBC访问Oracle与SQL Server时的区别
- [原创]使用DataList分页显示数据,双向排序,添加checkbox控件。
- 使用 Nginx 提升网站访问速度
- Firefox添加web浏览端口 "此地址访问受限 此地址使用了一个通常应该用于其他网页浏览的端口。由于安全原因,Firefox 取消了该请求。"
- 使用 awstats 分析 Nginx 的访问日志
- 使用DirectoryServices给文件添加访问权限
- 2.使用 Visual Studio Tools for Office(VSTO)访问Excel数据表
- 使用 awstats 分析 Nginx 的访问日志
- 【原创】使用yahoo雅虎js库(YUI)建立无刷新的N级树(可添加删除节点)
- [原创]JavaScript动态添加表格行(使用模板、标记)
- 如何解决ADO.NET访问Access数据库出现"操作必须使用一个可更新的查询"的问题(非原创,摘自书中)
- mysql grant 使用 授权 添加用户
- 使用DirectoryServices给文件添加访问权限
- 使用 Nginx 提升网站访问速度
- 技巧和诀窍:使用PrincipalPermissionAttribute在业务和数据层中添加授权规则
- 使用DirectoryServices给文件添加访问权限
- 技巧和诀窍:使用PrincipalPermissionAttribute在业务和数据层中添加授权规则
- 您未被授权查看该页 您不具备使用所提供的凭据查看该目录或页的权限 HTTP 错误 401.1 - 未经授权:访问由于凭据无效被拒绝。
- 使用 Nginx 提升网站访问速度
- 使用nginx作图片服务器的访问权限控制