AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 929817
Accepted
showkey
showkey
Asked: 2018-09-07 19:43:47 +0800 CST2018-09-07 19:43:47 +0800 CST 2018-09-07 19:43:47 +0800 CST

为什么apache需要使用用户名和密码对url进行授权?

  • 772

我在 apache 中建立了基本授权。在 .Only 中只有一行/var/www/html/remote.html。

<p>it is a test </p>

现在用 curl 验证用户名和密码。

curl -u xxxx:xxxx -v  http://111.111.111.111/remote.html
*   Trying 111.111.111.111...
* TCP_NODELAY set
* Connected to 111.111.111.111 (111.111.111.111) port 80 (#0)
* Server auth using Basic with user 'xxxx'
> GET /remote.html HTTP/1.1
> Host: 111.111.111.111
> Authorization: Basic dGVzdHBhc3M6MTIzNDU2Nzg=
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 07 Sep 2018 03:32:42 GMT
< Server: Apache/2.4.6 (CentOS)
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Authorization,DNT,User-Agent,Keep-Alive,Content-Type,accept,origin,X-Requested-With
< Last-Modified: Fri, 07 Sep 2018 03:22:41 GMT
< ETag: "b2-5753f8537e26c"
< Accept-Ranges: bytes
< Content-Length: 178
< Content-Type: text/html; charset=UTF-8
< 

<p>it is a test </p>
* Curl_http_done: called premature == 0
* Connection #0 to host 111.111.111.111 left intact

在浏览器中输入http://111.111.111.111/remote.html?username=xxxx&password=xxxx,弹出授权窗口。

在此处输入图像描述

url中包含正确的用户名和密码,通过curl验证,为什么不能直接显示remote.html?
为什么我的 urlhttp://111.111.111.111/remote.html?username=xxxx&password=xxxx不能向 apache 服务器提供授权信息?

apache-2.4
  • 3 3 个回答
  • 1851 Views

3 个回答

  • Voted
  1. lvc
    2018-09-07T19:52:06+08:002018-09-07T19:52:06+08:00

    HTTP 基本身份验证凭据在特定标头中从客户端发送到服务器 - 它们不会以这种方式附加到 URL。您可以通过注意这一点来验证这一点

    curl http://111.111.111.111/remote.html?username=xxxx&password=xxxx
    

    也不起作用 - 标志知道以不同的方式发送它,当您将凭据输入提供的表单时,-u您的浏览器也会这样做。

    • 1
  2. Best Answer
    RalfFriedl
    2018-09-07T21:12:32+08:002018-09-07T21:12:32+08:00

    基本认证的 URL 是

    http://testpass:[email protected]/remote.html
    
    • 1
  3. sanjayparmar
    2018-09-07T22:28:48+08:002018-09-07T22:28:48+08:00

    使用以下并检查其他答案以及如何输入登录 CLI

    curl --user user:pass http://myweb.com/hello.html  
    
    • 0

相关问题

  • Apache2 - SSL 不工作

  • Apache <VirtualHost> 标签,如果客户端的 IP = x 则不重定向... 怎么做?

  • 我无法启用我的网站?[关闭]

  • SELinux 阻止 Apache 写入文件

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve