快速搭建nginx,并做身份證校驗

  1. 安裝nginx
    yum -y install nginx

  2. 修改nginx配置
    vi /etc/nginx/nginx.conf

worker_processes  1;
events {
   worker_connections  1024;
}
http {
   include       mime.types;
default_type  application/octet-stream;
#添加upstream模塊
   upstream kibana_web {
   server 10.0.200.105:5601 weight=1 max_fails=2 fail_timeout=30s;
   }
   sendfile        on;
   keepalive_timeout  65;
   server {
       listen       5601;
       server_name  localhost;
       location / {
           auth_basic "The Kibana Monitor Center";
           auth_basic_user_file /usr/share/nginx/html/.htpasswd;
           root   html;
           index  index.html index.htm;
           proxy_set_header Host $host;
           proxy_pass http://kibana_web;
   }
       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
           root   html;
       }
   }
}

其中

auth_basic "The Kibana Monitor Center";
auth_basic_user_file /usr/share/nginx/html/.htpasswd; 配置權(quán)限
proxy_pass 做轉(zhuǎn)發(fā)用

3.添加用戶

htpasswd -c /usr/share/nginx/html/.htpasswd xxx

如果沒有htpasswd命令則

yum install httpd-tools 

4.如果需要多個用戶則每個用戶配置一個端口即可

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容