下記のURLを参考にNginxで指定ドメインのルートをBasic認証管理の設定を行いましたが、
Nginxの再起動等は問題なく動作するのですが、ページにアクセスしてもBasic認証が機能しません。
【バージョン】
環境 : さくらVPS
OS : CentOS Linux release 7.6.1810 (Core)
http : nginx version: nginx/1.14.2
【環境状態】
・「/var/www/html/」以下に各ドメインごとのディレクトリを作成
・各ドメインのルーティング設定は「/etc/nginx/conf.d/sites-enabled/example.com.conf」で管理
・SSL認証はLet's Encryptで設定
・パスワード設定ファイルは「/etc/nginx/.htpasswd」に記述
・「nginx -t」や「systemctl reload nginx」などのNginx起動のコマンドは通る(エラーは出ない)
・URLのページ自体も問題なくアクセスできる
【各ファイルソース】
# ① 「/etc/nginx/conf.d/sites-enabled/example.com.conf」 server { listen 80; listen 443 ssl; server_name www.example.com; root /var/www/html/example; access_log /var/log/nginx/example.com-access.log; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; return 301 $scheme://example.com$request_uri; location / { index index.html index.htm; try_files $uri $uri/ =404; # ここで認証設定 auth_basic "auth basic"; auth_basic_user_file /etc/nginx/.htpasswd; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
# ② 「/etc/nginx/conf.d/default.conf」 server { listen 80; server_name localhost; root /var/www/html; location / { root /var/www/html; index index.php index.html index.htm; } }
# ③ 「/etc/nginx/nginx.conf」 user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; include /etc/nginx/conf.d/*.conf; include /etc/nginx/conf.d/sites-enabled/*.conf; }
当方、Nginxの設定に抜け等の問題ではないかと思っているのですが、
確信を得られる原因がわからなかったのでご教示頂けると幸いです。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/21 02:57
2019/02/21 04:03
2019/02/21 04:06
2019/02/21 20:25