LINUX.ORG.RU
ФорумAdmin

Как в haproxy сделать редирект с http на https?

 , , ,


1

1

Пробую как в мануале делать. https://serversforhackers.com/using-ssl-certificates-with-haproxy

Работает, если по https:// заходить. Если по http то выдает:

Bad Request 
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Как сделать редирект с http на https?

Вот конфиг:

frontend myfrontend
bind *:80
bind *:443
option tcplog
mode tcp
default_backend nodes
backend nodes
mode tcp
balance roundrobin
option ssl-hello-chk
server web01 *.*.*.*:443 check

Ответ на: комментарий от blind_oracle

Пробую подгружать по прокси бэкенд с ssl, поэтому tcp.

Пробовал делать mode http, но в этом случае я не знаю как тянуть бэкенд по 443 порту.

mrblond
() автор топика
Ответ на: комментарий от blind_oracle
503 Service Unavailable No server is available to handle this request.
frontend http_frontend
    bind *:80
    bind *:443 ssl crt /etc/ssl/private/mysite.pem
    redirect scheme http if !{ ssl_fc }
    mode http
    default_backend nodes

backend nodes
    balance roundrobin
    option httpchk GET /health_check
    server web01 *.*.*.*:443 check weight 1 maxconn 100 ssl verify none
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
mrblond
() автор топика
Ответ на: комментарий от blind_oracle

Спасибо, убрал эту строчку, заработало. Исправил: redirect scheme https if !{ ssl_fc }

mrblond
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.