HAProxy community

SSL redirection

I want to redirect the request from http to https with out placing certificates in haproxy config file.

Unless you want to contribute a configuration sample, do not use that Category, instead use the help section.

To redirect from HTTP to HTTPS you don’t need a certificate.


frontend plainhttp
 bind :80
 http-request redirect scheme https

But I guess actually need something else … so please elaborate what you are trying to do exactly if this does not answer your question.

The page is getting redirected but we are getting error (ERR_TOO_MANY_REDIRECTS)

below is the config file

frontend gateway
mode http
option httplog
bind :80
http-request redirect scheme https
acl acl_scg_gateway_api_path hdr(host) -i
acl acl_scg_frontend_api_path hdr(host) -i
acl acl_scg_api_path path -i -m beg /api /webhooks
acl acl_scg_frontapi_path path -i -m beg /
acl acl_scg_iot_path path -i -m beg /apidata
acl acl_scg_callback_path path -i -m beg /callback/initiate
http-request use-service lua.cors-response if METH_OPTIONS
use_backend callback_redirect if acl_scg_gateway_api_path acl_scg_callback_path
use_backend callback_frontredirect if acl_scg_frontend_api_path acl_scg_frontapi_path
use_backend iot-%[req.hdr(client_id)] if acl_scg_gateway_api_path acl_scg_iot_path
use_backend %[req.hdr(client_id)] if !acl_scg_iot_path !acl_scg_callback_path acl_scg_gateway_api_path

backend callback_frontredirect
mode http
balance roundrobin
server server1 :
server server2 :

backend callback_redirect
mode http
http-request use-service lua.callback_redirect
backend 1001
mode http
server server1 : check
backend iot-1001
mode http
server server1 : check

What’s all the rest of the configuration supposed to do? Please explain what you are trying to achieve in it’s entirety, otherwise nobody will be able to help for sure.

Whatever is listening on port 443 then doesn’t like your redirect (redirecting back to port 80 and causing infinite redirects).

Hi @lukastribus,

I am trying to filter the request from the URL and based on the URL I am trying to send the requests to specific backend/URL to serve the request so for this I created a config related to this which is shared above on the comment.
Now my domain is xyz.com suppose anyone will hit on http://xyz.com I want it to get redirected on https://xyz.com