nginx让用户通过用户名密码认证访问web页面
# vim /usr/local/nginx/conf/nginx.conf //主配置文件中http字段中添加以下语句userroot;
worker_processes1;
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
#pid logs/nginx.pid;
events {
worker_connections1024;
}
http {
include mime.types;
default_typeapplication/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout0;
keepalive_timeout65;
server {
listen 80;
server_namelocalhost;
location / {
root html;
indexindex.html index.htm;
}
error_page 500 502 503 504/50x.html;
location = /50x.html {
root html;
}
}
server {
listen 12171;
server_namelocalhost;
client_max_body_size 151m;
location / {
auth_basic "s1";#虚拟主机认证命名
auth_basic_user_file /usr/local/nginx/passwd.db; #虚拟主机用户名密码认证数据库
#proxy_pass http://10.0.0.10:9011;#nginx 访问
root html;
indexindex.html index.htm;
}
}
server {
listen 12172;
server_namelocalhost;
client_max_body_size 151m;
location / {
auth_basic "s1";#虚拟主机认证命名
auth_basic_user_file /usr/local/nginx/passwd.db; #虚拟主机用户名密码认证数据库
proxy_pass http://10.0.0.10:8088;#hadoop 访问
}
}
页:
[1]