# 编译 tar zxvf nginx-1.16.0.tar.gz cd nginx-1.16.0 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make make install # 验证是否安装成功 cd /usr/local/nginx ./sbin/nginx -t
安装apache-htpasswd工具
yum -y install httpd-tools
配置认证账号
cd /usr/local/nginx/conf # 账号admin ,然后设置密码 htpasswd -c ht.passwd admin
在nginx.conf配置
server { listen 80; client_body_buffer_size 20m; server_name ~^(.+)?.twf.cn$; if ($host = prometheus.twf.cn){ rewrite ^(.*)$ https://$host$1 permanent; } }
server { listen 443 ssl; server_name ~^(.+)?.twf.cn$; client_body_buffer_size 20m;