V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
handwork
V2EX  ›  NGINX

nginx 下配置了 htpasswd,依然可以直接访问 PHP 文件

  •  
  •   handwork · Jan 11, 2018 · 3854 views
    This topic created in 3033 days ago, the information mentioned may be changed or developed.

    nginx 下配置了 htpasswd,html 是可以通过用户名密码访问了,但 php 文件还是可以直访问,配置如下,哪儿有问题?

    		#访问验证
    		location / {
    			auth_basic  "welcome";
    			auth_basic_user_file /setting/db.txt;
    		}
    
    3 replies    2018-01-12 08:04:47 +08:00
    sparkssssssss
        1
    sparkssssssss  
       Jan 11, 2018
    你有单独的处理 php location 吧,这个指示针对 /吧
    handwork
        2
    handwork  
    OP
       Jan 11, 2018
    @coolloves 谢谢提醒,这样就 OK 了!
    ````
    #访问验证
    location / {
    auth_basic "welcome";
    auth_basic_user_file /setting/db.txt;
    include enable-php-pathinfo.conf;
    }
    ```
    julyclyde
        3
    julyclyde  
       Jan 12, 2018
    很多例子把 location php 套在 location / 内部
    问题是 nginx 并不是这么理解的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2310 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 01:33 · PVG 09:33 · LAX 18:33 · JFK 21:33
    ♥ Do have faith in what you're doing.