1,首先安装nginx
yum install -y nginx
2,生成密钥文件
安装htpasswd工具
yum install -y httpd-tools
生成密钥文件,prometheus为用户名
htpasswd -c /etc/nginx/conf.d/passwd prometheus
3,修改nginx配置文件nginx.conf,增加如下内容
upstream vmselect {server 10.250.5.74:8901 weight=5 ;server 10.250.5.75:8902 weight=5 ;server 10.250.5.76:8903 weight=5 ;}server {listen 8900;server_name _;auth_basic "authentication"; # 开启基本认证auth_basic_user_file /etc/nginx/conf.d/passwd; # 密码文件location / {proxy_pass http://vmselect/select/0/prometheus/;}}upstream vminsert {server 10.250.5.74