Redirecting HTTP to HTTPS


I am trying to simple route all the HTTP requests made to the server to redirect as HTTPS to external server.

Can you please help with the it?

frontend localhost
bind :80
option tcplog
mode tcp
default_backend nodes

backend nodes
mode tcp
option ssl-hello-chk
server sv1 10.192.x.x:443

Also I am trying to use curl (below command) and it should redirect to https://v1/health to fetch the data.
The https url works without any issue, so there is no connectivity issue from the machine. But the localhost url
doesn’t work.

curl -X GET http://localhost/health
curl: (52) Empty reply from server

curl -X GET https://sv1/health

Would you like to redirect (send a redirect message to the client to let him connect directly the https on port 443), then remove the backend and just put this in your port 80 frontend:

redirect scheme https

(you don’t even need the if !{ ssl_fc } condition, as in a port 80 frontend you already know it’s not encrypted).

Or would you like to “route” the traffic to your secure backend, by stripping SSL from it. Then you need to add the ssl (and probably verify none) keyword to your server sv1 line (so that SSL is used to connect to it):

server sv1 10.192.x.x:443 ssl verify none

Basically we have installed HAPROXY in between the client application server and the service-provider server

Client app server can only make http calls, whereas the service-provider server accepts only https calls with certificate for incoming traffic.

So we are planning to use HAProxy to listen to the client on 80 and in the backend convert the call as HTTPS

So its not a redirect. From my previous post, use the latter configuration.