OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 22.7 Legacy Series »
  • HAProxy Virtual IP Bind Issue
« previous next »
  • Print
Pages: [1]

Author Topic: HAProxy Virtual IP Bind Issue  (Read 2352 times)

authelia

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
HAProxy Virtual IP Bind Issue
« on: August 29, 2022, 10:12:41 am »
Whenever I add a virtual ip and configure haproxy to listen to it on ports 80/443, I can't start:

1. haproxy (when webui is running) or
2. webui (when haproxy is running)

This issue seems very similar to the one reported for v22.1.

Patch 9a618ba6 doesn't seem to work on OPNsense 22.7.2-amd64.
Error message:

Code: [Select]
root@OPNsense:/var/log/system # opnsense-patch 9a618ba6
Found local copy of 9a618ba6, skipping fetch.
2 out of 6 hunks failed while patching etc/inc/interfaces.inc

Virtual ip is attached to lo0 with service binding disabled. I was trying to follow the haproxy tutorial
« Last Edit: August 30, 2022, 05:58:18 am by authelia »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17750
  • Karma: 1620
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #1 on: August 29, 2022, 11:24:06 am »
I'm not aware of issues with 22.7. If you add a patch from 22.1 you will most likely remove the actual fix.

If you want to grab port 80 make sure to disable the web GUI redirect.


Cheers,
Franco
Logged

Bunch

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 8
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #2 on: August 29, 2022, 12:57:58 pm »
It's not the same issue reported in 22.1.
The issue in 22.1 have nothing related to webui.

If you find only one of them can survive in your setting
Please make sure that only one of below statements can be true (If both statement true, your thing won't work)
1. In HAProxy, one of your frontends is binding to 0.0.0.0:80, or 0.0.0.0:443 or (WAN_IP):80 or (WAN_IP):443
2. In webui, you haven't changed the port and haven't disabled auto redirect, i.e. it's still using port 443 or 80

BTW, I'm afraid applying patches from totally different versions will break the code. (You might have strange issue even you have your HAProxy and webui setup correctly)
Logged

authelia

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #3 on: August 29, 2022, 10:35:00 pm »
How can I reverse the wrong patch? Reapplying the same command doesn't seem to work.

Quote
Please make sure that only one of below statements can be true (If both statement true, your thing won't work)
1. In HAProxy, one of your frontends is binding to 0.0.0.0:80, or 0.0.0.0:443 or (WAN_IP):80 or (WAN_IP):443
2. In webui, you haven't changed the port and haven't disabled auto redirect, i.e. it's still using port 443 or 80

In my case, only (2) is true. I haven't changed the standard port and HTTP Redirect is unchecked.

Do I still need (1) if I have defined virtual ip?
« Last Edit: August 30, 2022, 06:25:09 am by authelia »
Logged

Bunch

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 8
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #4 on: August 30, 2022, 02:58:08 am »
Quote from: authelia on August 29, 2022, 10:35:00 pm
How can I reverse the wrong patch? Reapplying the same command doesn't seem to work.

Code: [Select]
Please make sure that only one of below statements can be true (If both statement true, your thing won't work)
1. In HAProxy, one of your frontends is binding to 0.0.0.0:80, or 0.0.0.0:443 or (WAN_IP):80 or (WAN_IP):443
2. In webui, you haven't changed the port and haven't disabled auto redirect, i.e. it's still using port 443 or 80

In my case, only (2) is true. I haven't changed the standard port and HTTP Redirect is unchecked.

Do I still need (1) if I have defined virtual ip?

It is advised to, as we don't know the config of your HAProxy, so we are unable to guess how it failed.
And it is better to ask in that tutorial thread.
Logged

authelia

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #5 on: August 30, 2022, 06:23:28 am »
Thanks Bunch and Franco for your assistance thus far.

Quote
It is advised to, as we don't know the config of your HAProxy, so we are unable to guess how it failed.

I have added the frontend listener for 0.0.0.0 as per the tutorial. However, as soon as I enable the frontend listener for the virtual ip, haproxy refuses to start.

What I am noticing is that as soon as the webgui starts up, lighttpd binds port 80 and 443 to the virtual ip (even though "Allow Services Binding" option is unchecked).

I even tried using a completely brand new subnet as the new virtual ip (unrelated to any of the interfaces). However, the same symptoms appear.

For example, changing the virtual ip to 192.168.10.65 (from 192.168.1.65 - LAN subnet is 192.168.1.0/24), I see the following as soon as the webgui is restarted.

Virtual IP in LAN Subnet

Code: [Select]
root@OPNsense:~ # sockstat -4 -l | grep lighttpd
root     lighttpd   28364 6  tcp4   192.168.1.65:443      *:*
root     lighttpd   28364 8  tcp4   192.168.1.1:443       *:*
root     lighttpd   28364 10 tcp4   192.168.1.65:80       *:*
root     lighttpd   28364 12 tcp4   192.168.1.1:80        *:*
root     sshd       84263 5  tcp4   192.168.1.1:22        *:*

root@OPNsense:~ # /usr/local/etc/rc.d/haproxy start
Starting haproxy.
[ALERT]    (2036) : Starting frontend 1_HTTP_frontend: cannot bind socket (Can't assign requested address) [192.168.1.65:80]
[ALERT]    (2036) : Starting frontend 1_HTTPS_frontend: cannot bind socket (Can't assign requested address) [192.168.1.65:443]
[ALERT]    (2036) : [/usr/local/sbin/haproxy.main()] Some protocols failed to start their listeners! Exiting.
/usr/local/etc/rc.d/haproxy: WARNING: failed to start haproxy

Virtual IP in Brand New Subnet

Code: [Select]
root@OPNsense:~ # /usr/local/etc/rc.restart_webgui
Starting web GUI...done.
Generating RRD graphs...done.

root@OPNsense:~ # sockstat -4 -l | grep lighttpd
root     lighttpd   64654 6  tcp4   192.168.10.65:443     *:*
root     lighttpd   64654 8  tcp4   192.168.1.1:443       *:*
root     lighttpd   64654 10 tcp4   192.168.10.65:80      *:*
root     lighttpd   64654 12 tcp4   192.168.1.1:80        *:*
root     sshd       84263 5  tcp4   192.168.1.1:22        *:*

root@OPNsense:~ # /usr/local/etc/rc.d/haproxy start
Starting haproxy.
[ALERT]    (18033) : Starting frontend 1_HTTP_frontend: cannot bind socket (Address already in use) [192.168.10.65:80]
[ALERT]    (18033) : Starting frontend 1_HTTPS_frontend: cannot bind socket (Address already in use) [192.168.10.65:443]
[ALERT]    (18033) : [/usr/local/sbin/haproxy.main()] Some protocols failed to start their listeners! Exiting.
/usr/local/etc/rc.d/haproxy: WARNING: failed to start haproxy
Logged

authelia

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #6 on: August 30, 2022, 06:57:12 am »
As advised, I have also cross posted on the original support thread.
Logged

Patrick M. Hausen

  • Hero Member
  • *****
  • Posts: 6935
  • Karma: 584
    • View Profile
Re: HAProxy Virtual IP Bind Issue
« Reply #7 on: August 30, 2022, 08:44:33 am »
Your web UI is listening on that port already. I suggest you move it to something different like 4443. That's what we do.
Logged
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 22.7 Legacy Series »
  • HAProxy Virtual IP Bind Issue
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2