devops
devops

Reputation: 193

HAproxy is not forwarding request from http to https while using curl through command line

I have configured HAProxy.This will redirect certain domain from http to https through browser. And it satisfy all my requirement through browser.

But when i try to use the api through curl(command line) it is not working when i use http://

Here is doubt is how i can redirect all curl or command line request which is http to https. Here is the output when i tried to use 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

Thanks, Prash

Upvotes: 1

Views: 1039

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 178956

HAProxy seems to be working exactly as it should.

The problem you have is that curl doesn't honor HTTP redirects unless you explicitly tell it to do so, by adding the -L or --location command line option.

Upvotes: 2

Related Questions