当通过命令行使用curl时,HAproxy并没有将请求从http转发到https



我已经配置了HAProxy。这将通过浏览器将某些域从http重定向到https。它通过浏览器满足了我的所有需求。

但是,当我尝试通过curl(命令行)使用api时,当我使用http://

这里的疑问是我如何重定向所有的curl或命令行请求(http到https)。以下是我尝试使用http curl时的输出。

$ curl -s -v  -u $USER:$PASS -X GET -H "Content-Type: application/json" http://<IP>/rest/api/2/project/
*   Trying 192.168.1.21...
* Connected to test-jira.example.com (192.168.1.21) port 80 (#0)
* Server auth using Basic with user 'prash.castlestreet'
GET /rest/api/2/project/ HTTP/1.1
Host: prash.castlestreet.example.com
Authorization: Basic cHJhZGVlcC5jaGVydXRodWRpeWlsZ2lyaWphdmFsbGFiaGFuOlZlcml6b24h
User-Agent: curl/7.43.0
Accept: */*
Content-Type: application/json
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-length: 0
Location: https://prash.castlestreet.example.com/rest/api/2/project/
Connection: close
Closing connection 0

谢谢,Prash

HAProxy似乎正按照它应该的方式工作。

问题是curl不接受HTTP重定向,除非您通过添加-L--location命令行选项明确告诉它这样做。

相关内容

最新更新