默認主機修改爲 listen 80 default_server;
用戶證(nginx用戶認證需要藉助apache的認證腳本)需要安裝apache,可以使用yum install httpd 安裝
生成密碼文件,創建用戶 /usr/local/apache2/bin/htpasswd -c /usr/local/nginx/conf/.htpasswd admin
輸入創建密碼
編輯nginx代理配置文件 vi /usr/local/nginx/conf/vhosts/default.conf 在root /data/www下面添加
location /uc_server/ {
auth_basic "Auth";
auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
}
/usr/local/nginx/sbin/nginx -t 檢測配置文件
/usr/local/nginx/sbin/nginx -s reload 重新加載配置文件
web訪問網站 需要輸入用戶 admin 密碼:創建的密碼