php ngx_http_auth_basic_module,tengine 默认开启ngx_http_auth_basic_module 了吗?

我这里测试没有问题

配置如下

worker_processes 1;

events {

worker_connections 1024;

}

http {

req_status_zone server "$host,$server_addr:$server_port" 10M;

req_status_zone_add_indicator server $limit;

server {

listen 18080;

location /us {

auth_basic "nginx basic http test for ttlsa.com";

auth_basic_user_file conf/htpasswd;

req_status_show;

req_status_show_field req_total $limit;

}

set $limit 0;

if ($arg_limit = '1') {

set $limit 1;

}

req_status server;

}

}

Chrome version: 64.0.3282.186 (Official Build) (64-bit)

测试页面返回:

这条请求对应日志:*** - - [07/Mar/2018:23:32:34 +0800] "GET /us HTTP/1.1" 401 659 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36")

387cdb168a3ed6987aade657287ab6a1.png

如果你直接访问/us返回的是401就说明模块和配置没有异常 (如果浏览器还是无法提升密码输入框,可能是浏览器自身问题)

$ curl localhost:18080/us -i

HTTP/1.1 401 Unauthorized

Server: Tengine/2.2.2

Date: Wed, 07 Mar 2018 15:34:14 GMT

Content-Type: text/html

Content-Length: 654

Connection: keep-alive

WWW-Authenticate: Basic realm="nginx basic http test for ttlsa.com"

401 Authorization Required

401 Authorization Required

This server could not verify that you are authorized to access the document requested. Sorry for the inconvenience.

Please report this message and include the following information to us.

Thank you very much!

URL:http://localhost:18080/us
Server:e100069206110.zmf
Date:2018/03/07 23:34:14

Powered by Tengine/2.2.2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值