AnswerBun.com

How haproxy frontend not 443 port balance backend 443?

Server Fault Asked by PZY on December 2, 2020

my haproxy configuration is:

# Configuration for 678da17a-5c8f-4d2b-9431-f3019aae9726
global
    daemon
    user nobody
    group haproxy
    log /dev/log local0 debug alert
    log /dev/log local1 notice alert
    maxconn 2000
    stats socket /var/lib/neutron/lbaas/v2/678da17a-5c8f-4d2b-9431-f3019aae9726/haproxy_stats.sock mode 0666 level user

defaults
    log global
    retries 3
    option redispatch
    timeout connect 5000
    timeout client 50000
    timeout server 50000

frontend 8e85521c-f92b-401a-a72f-9f3d9dbd9deb
    option tcplog
    bind 123.44.44.44:5200
    mode tcp
    default_backend 46a948a1-1043-437d-83d0-e25acf0c94fd

backend 46a948a1-1043-437d-83d0-e25acf0c94fd
    mode tcp
    balance roundrobin
    server 9add0118-0255-4ee3-998a-875fb251624b 123.23.23.23:443 weight 1

I want to configure frontend using 5200 port to access backend server 123.23.23.23:443.
But when i request https://123.44.44.44:5200, the request change to https://123.44.44.44/index.html. It leads to request failure.
Why happens that?

One Answer

HAProxy is requesting https://123.44.44.44/ from the backend. That's the root directory and not actually a file, so the backend responds by redirecting the browser to the default (index.html) file, which from the backend's perspective is at https://123.44.44.44/index.html. Confirm this by using developer tools in your browser and you'll likely see the 301 code.

There's (at least) two ways to handle that. First is on the backend web server - the backend knows nothing about port 5200 unless you configure it to. Second is in HAProxy by rewriting the Location: header, e.g.

http-request replace-header Location ^https://123.44.44.44/(.*)$ https://123.44.44.44:5200/1

If you use the HAProxy approach, note that you would need to do it for IP addresses and domain names separately (if you will be accessing using both and want both to work).

Answered by tater on December 2, 2020

Add your own answers!

Related Questions

Enabling jumbo frame on tg3

0  Asked on December 15, 2020 by gli-illuminati

     

Postfix does not retry after 451 error / greylisting

2  Asked on December 14, 2020 by assylias

       

OpenVPN over dynamic IPv6

1  Asked on December 14, 2020 by hellstorm

   

autossh does not kill ssh when link down

1  Asked on December 13, 2020

   

Is it safe to write batch files with Unix line endings?

4  Asked on December 13, 2020 by cmcginty

   

On demand new IPv6 using privacy extension?

1  Asked on December 12, 2020 by wannabecoder

         

nginx, gitlab, subdomain

1  Asked on December 10, 2020 by emidee

       

Move Access 2016 Database to Azure?

0  Asked on December 9, 2020 by user601108

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir