Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] HAProxy Transparent Mode IPFW #1883

Closed
NunoHiggs opened this issue Oct 19, 2017 · 8 comments
Closed

[REQUEST] HAProxy Transparent Mode IPFW #1883

NunoHiggs opened this issue Oct 19, 2017 · 8 comments
Assignees
Labels
feature Adding new functionality help wanted Contributor missing / timeout

Comments

@NunoHiggs
Copy link

NunoHiggs commented Oct 19, 2017

This is an extract of a request by user @rosu form this forum thread.

What I modified is basically as per the post I mentioned previously:

Create a new file /usr/local/etc/ipfw_custom.rules for the custom IPFW rules:

Code:

add 3000 fwd localhost tcp from ${server_ip} 80 to any in recv vmx1

Modify /usr/local/etc/rc.ipfw to include the custom rules
Code: [Select]

/sbin/ipfw -f /usr/local/etc/ipfw.rules
if [ -f /usr/local/etc/ipfw_custom.rules ]; then
/sbin/ipfw -f /usr/local/etc/ipfw_custom.rules
fi

Modify /usr/local/opnsense/service/templates/OPNsense/IPFW/rc.conf.d to enable IPFW
Code: [Select]

firewall_enable="{% if shapers or cp_zones %}YES{% else %}YES{% endif %}"

Then you can configure a backend in HAProxy via the Option pass-through section to use the client IP address as the source:
source 0.0.0.0 usesrc clientip

Just have to ensure that OPNsense is the default gateway for the servers you are load balancing. I believe there is an option called Transparent ClientIP on the pfSense HAProxy addin which will configure IPFW rules etc.

Is it possible to incorporate HAProxy Transparent Mode IPFW thru the opnsense webgui?

Thanks!
Nuno

@NunoHiggs
Copy link
Author

Hello? Is it possible?

@fraenki
Copy link
Member

fraenki commented Nov 16, 2017

Is it possible to incorporate HAProxy Transparent Mode IPFW thru the opnsense webgui?

Technically speaking it might be possible, but I'm unsure if it's possible to properly integrate it.

That being said, as the current maintainer of the HAProxy plugin I will not be able to work on this for several months. Contributions/patches are welcome, though.

@fraenki
Copy link
Member

fraenki commented Nov 16, 2017

@fichtner Please assign to me (and add the "help wanted" label).

@fichtner fichtner added feature Adding new functionality help wanted Contributor missing / timeout labels Nov 16, 2017
@AdSchellevis
Copy link
Member

Can't you just use the nat/forward options already in OPNsense (which uses pf), just like our proxy does?
(the link used to template the squid rules)
https://fw-ip/firewall_nat_edit.php?template=transparent_proxy

If there's anything missing there, we should be able to add it, but when possible we tend to use pf for our firewall and only ipfw for edge cases (like captive portal and traffic shaping).

@NunoHiggs
Copy link
Author

@AdSchellevis was that question for me? I would if i knew how :)

PS: thanks for all of your hard work!

@AdSchellevis
Copy link
Member

@NunoHiggs yes, that question was indeed for you :) I would start using the template rule which you can create using the above link and alter the parameters to match your situation.

@NunoHiggs
Copy link
Author

NunoHiggs commented Nov 18, 2017

@AdSchellevis i've been trying with the transparent proxy template like you said, but i cannot get it to work.
Using the template i get a transparent nat but
config
it bypasses the HAproxy all together and i am not getting the client IP on the endpoint where the HAproxy connects to that was the intended result.

@fraenki
Copy link
Member

fraenki commented Aug 2, 2018

In many situations there are alternative ways available to get the client IP:

  • Use HAProxy in HTTP(S) mode and enable the X-Forwarded-For header
  • Use HAProxy's PROXY protocol if your application supports it (Dovecot, Postfix)

I'll close this issue now, but if someone wants to work on this we'll reopen it of course.
(@AdSchellevis, since this issue was created in core, would you please close it please?)

@fichtner fichtner closed this as completed Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding new functionality help wanted Contributor missing / timeout
Development

No branches or pull requests

4 participants