2016-09-27 63 views
0

問題,我有一個Nginx的虛擬主機具有以下內容:授權(401)與Nginx的

server { 
    listen 80; 
    location /.well-known { 
     alias /usr/local/etc/letsencrypt-webroot/.well-known; 
    } 
    return 301 https://$host$request_uri; 
} 

server { 
    listen 443 ssl; 
    ssl_certificate /etc/letsencrypt/live/sub.domain.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/sub.domain.com/privkey.pem; 
    ssl_dhparam /etc/nginx/ssl/dh.pem; 

     add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; 

    location/{ 
     proxy_pass http://127.0.0.1:3000; 
     proxy_cookie_path/"/; secure; HttpOnly"; 
     auth_basic "No no no!"; 
     auth_basic_user_file /etc/nginx/.htpasswd; 
    } 
} 

我有一個問題,當URL是/.well-known/...。我得到一個401,因爲它不斷要求憑證。

所以我的問題是:

  • 爲什麼/.well-known用戶保護?不應該在SSL部分到達location /之前處理它,這是需要驗證的部分嗎?

  • 我該如何解決這個問題?基本上我需要的一切要求代理需要認證,除了/.well-known

回答

0

嘗試打開http://yourserver/.well-known/而不是https://yourserver/.well-known

如果此作品重新考慮將兩個位置塊移至單個server {...}塊。

//編輯使其工作,你必須刪除重定向。或者將其添加到https服務器定義中的阻止中。

+0

我正在使用http。將'.well-known'塊移動到其他部分工作。 – yzT