2010-08-24 22 views
0

我有一個文件夾f控制多個HTML文件權利從一個文件夾的nginx&auth_basic

  • A.html
  • B.html
  • C.html
  • 的index.html
  • 提供文件服務

它們是由sphinx自動生成的python doc。

我想讓我的url/foo顯示B.html不受限制,但其他所有內容都應該使用auth_basic「Restricted」提示輸入密碼。

到目前爲止,我嘗試沒有成功

location /foo { 
    index B.html; 
    alias /home/novagile/www/doc_novasniff/doc/_build/html; 
    auth_basic   "off"; 


} 
location /foo { 
    index index.html; 
    alias /home/novagile/www/doc_novasniff/doc/_build/html; 
    auth_basic   "Restricted"; 
    auth_basic_user_file /etc/nginx/htpass; 

} 

的幫助是值得歡迎以下,

格雷格

回答

0

嘗試。

location ~ ^/foo/?$ { 
    root /home/novagile/www/doc_novasniff/doc/_build/html; 
    rewrite^/B.html break; 
} 
location ~ ^/foo/(.+)$ { 
    alias /home/novagile/www/doc_novasniff/doc/_build/html/$1; 
    index index.html; 
    auth_basic "Restricted"; 
    auth_basic_user_file /etc/nginx/htpass; 
}