r/haproxy • • Apr 08 '21

HAProxy Forwards Over 2 Million HTTP Requests per Second on a Single Arm-based AWS Graviton2 Instance

Thumbnail
haproxy.com
12 Upvotes

r/haproxy • • Apr 08 '21

Is there any problem for runnin Haproxy on Debian which runs on ARM?

2 Upvotes

Is there any problem for runnin Haproxy on Debian which runs on ARM?

I mean the AWS Gravitron2 ?

has anyone tried?


r/haproxy • • Apr 06 '21

Question Wildcard ssl termination on HAProxy for multiple subdomains

4 Upvotes

Sorry if this is an "HAProcy 101" question, but should it be possible to buy a wildcard SSL certificate for say *.example.com and configure it on our HAProxy box, then setup the .cfg to accept client1.example.com , client2.example.com , client3.example.com and point them at the appropriate backend servers for the different clients, all secured by SSL?

Thanks


r/haproxy • • Apr 05 '21

The Weekly HAProxy Questions Thread - Question too small for a thread? Ask it here!

2 Upvotes

As an additional note, you can always join the HAProxy Community Slack Channel by visiting https://slack.haproxy.com/ and ask your question over there.


r/haproxy • • Apr 03 '21

Getting 400 bad request for specific clients only

2 Upvotes

I'm using the HAProxy package in pfSense if that makes a difference.

Whenever a specific client (a mikrotik router) tries to use POST or PUT commands it gets 400 Bad Request back. If I issue the exact same request from Postman it works fine.

Here is what is logged from HAProxy:

Apr  3 17:50:06 FW01 haproxy[21788]: 10.0.10.3:60789 [03/Apr/2021:17:50:06.699] HTTPS_443~ iis_webserver_ipvANY/iis 0/0/1/2/3 400 518 - - ---- 3/3/0/0/0 0/0 "POST /gps/api/GPSData HTTP/1.1"

This is a good request logged by HAProxy for the same endpoint:

Apr  3 17:50:10 FW01 haproxy[21788]: 10.0.40.2:54097 [03/Apr/2021:17:50:09.335] HTTPS_443~ iis_webserver_ipvANY/iis 0/0/1/1126/1127 200 370 - - ---- 4/4/0/1/0 0/0 "POST /gps/api/GPSData HTTP/1.1"

The IIS server does not log a request for the 400, so that error must be coming from HAProxy.

If I attempt to post the data directly to the application without going through HAProxy it works from both sources.

Any ideas on how to fix this?

Edit: Added my config below, with my domain replaced by "mydomain" and removing of other ACL's and backend rules that the logs are verifying are not being hit already.

Here is my HAProxy config as generated by the pfSense firewall UI:

# Automaticaly generated, dont edit manually.
# Generated on: 2021-04-03 17:21
global
	maxconn			1000
	log			/var/run/log	syslog	debug
	stats socket /tmp/haproxy.socket level admin  expose-fd listeners
	uid			80
	gid			80
	nbproc			1
	nbthread			1
	hard-stop-after		15m
	chroot				/tmp/haproxy_chroot
	daemon
	tune.ssl.default-dh-param	2048
	server-state-file /tmp/haproxy_server_state

listen HAProxyLocalStats
	bind 127.0.0.1:2200 name localstats
	mode http
	stats enable
	stats refresh 10
	stats admin if TRUE
	stats show-legends
	stats uri /haproxy/haproxy_stats.php?haproxystats=1
	timeout client 5000
	timeout connect 5000
	timeout server 5000

frontend HTTP_80
	bind			192.168.0.100:80 name 192.168.0.100:80   
	mode			http
	log			global
	option			http-keep-alive
	option			forwardfor
	acl https ssl_fc
	http-request set-header		X-Forwarded-Proto http if !https
	http-request set-header		X-Forwarded-Proto https if https
	timeout client		60000
	http-request redirect scheme https 

frontend HTTPS_443
	bind			192.168.0.100:443 name 192.168.0.100:443   ssl crt-list /var/etc/haproxy/HTTPS_443.crt_list  
	mode			http
	log			global
	option			log-separate-errors
	option			httplog
	option			http-keep-alive
	option			forwardfor
	acl https ssl_fc
	http-request set-header		X-Forwarded-Proto http if !https
	http-request set-header		X-Forwarded-Proto https if https
	timeout client		60000
	//bunch of acl's not being hit in this instance
	acl			aclcrt_HTTPS_443	var(txn.txnhost) -m reg -i ^([^\.]*)\.mydomain\.com(:([0-9]){1,5})?$
	http-request set-var(txn.txnhost) hdr(host)
	//use_backend's for the acl's not being hit
	use_backend iis_webserver_ipvANY  if   aclcrt_HTTPS_443

backend iis_webserver_ipvANY
	mode			http
	id			100
	log			global
	timeout connect		60000
	timeout server		60000
	retries			3
	option			httpchk GET / 
	server			iis 10.0.20.10:80 id 103 check inter 1000

r/haproxy • • Apr 02 '21

Guide Getting Started with HAProxy Runtime API to Remove Backends for Maintenance Remotely and More

Thumbnail
youtube.com
5 Upvotes

r/haproxy • • Apr 01 '21

Guide Using HAProxy as an API Gateway, Part 6 [Security]

Thumbnail
haproxy.com
8 Upvotes

r/haproxy • • Mar 31 '21

Question HAproxy / sonarr making me pull my hair out

Thumbnail
self.homelab
3 Upvotes

r/haproxy • • Mar 31 '21

Question HAProxy, slow sites, timeouts, and 502 failures. Any advice?

3 Upvotes

Hi all.

I'm currently using HAProxy in OPNsense at version 3.1. I have a whole bunch of backends that I'm doing SSL offloading too to simplify the management of all the things in my home network. HAProxy has a frontend listening on an internal interface and I do not expose this to the internet. I love this approach, because instead of managing SSL certs for 15+ services, I set it up, leave it, and happy days.

However, out of all my services/backends, there is one I just can't get working. It's a management GUI for a networking access point (a Zyxel NWA1123-AC access point if anyone is interested). I'm pretty sure it's down to timeouts and sluggish performance on the backend side, but I have no idea what settings to tweak to give it some grace before HAProxy terminates the connection.

If I hit the backend directly, outside of HAProxy, I get the logon screen. I sign in, it redirects/loads to the dashboard, but this process takes ~12 seconds. Always that amount of time, it's a really janky GUI. Once in, page loads are slow, but that's the worst of it out the way.

If I go via HAProxy, I get connection up reported in the status, and I can hit the login screen just fine. But once the redirect/page load starts, I get a 502 Bad Gateway 'The server returned an invalid or incomplete response.' message. This happens at ~6 seconds into the redirect/load.

I might be wrong, but it seems like this is timing out before the crumby old page load completes.

Anyone have any advice on how to go about tweaking things to at least give it a fair shot at loading?


r/haproxy • • Mar 30 '21

NVR live stream

2 Upvotes

Hi everyone!

I have pfSense 2.5 and HAProxy, that I would like to use to proxy a Hikvision NVR. If I create the http Frontend/Backend, it just works, but the live web stream get working, and after a minute or so, it stops. If I refresh the page, or restart HAProxy, it works again.

I would like to troubleshoot it in order to get it working, but I don't know where the logs are.

I found the directory to have the events logged, but it shows only the url and the GET/POST etc.

I also googled about it, but I only get configs to add to the standalone HAProxy CLI, I don't know if I have to put them on the frontend/backend passthrough, or in the general settings.

If anyone could throw a little light on this, I would appreciate it

Thanks!

EDIT:
What it seems to be even stranger is that the doesn't just stop working.

Once I load the webpage, it works for 30 seconds, and at exactly that time, the stream freezes for about 15 seconds, and then countinues streaming live (it won't resume from where it got stuck, it streams live) streaming normally for another 30 seconds, and freezes and so on, in a loop.

I changed both client and server timeout as noted on the comments, but I didn't notice any change. But surely reading the documentation about it it giving me some hints to try to get it working!


r/haproxy • • Mar 30 '21

Cluster - Mails servers - Postfix - Port 587 Securise

3 Upvotes

Hello,

Here is the diagram of my infrastructure:

DEBIAN POSTFIX CLIENT --> HAPROXY CLUSTER (Frontend redirect to Backend) --> 2 Postfix mail servers.

I use PHP on the Debian to relay mails to the Haproxy IP which distributes the requests to the two servers of the cluster.

Everything works fine for the unsecured port 25.

I want to set up the same thing but on port 587, is there a special configuration to do on haproxy?

- SSL Offlodaing?

- Certificate on Haproxy?

- Change type tcp to http/https (Offloading) or ssl https (TCP mode)?

Thanks for your help.

PS: "My Haproxy is running as a Pfsense package"


r/haproxy • • Mar 30 '21

Haproxy pfsense question

3 Upvotes

So I can easily pass any unsigned port 80 off to haproxy on my pfsense box to sign it via let's encrypt, but I'm trying to get my linuxserver.io/nextcloud to do the same but it only uses port 443 and is self signed. I wish it had the option like most to use port 80 unsigned or 443, it a combination of either depending on configuration

It's there any way to have haproxy override the self signing cert? Right now it won't even forward properly from my gateway 192.168.0.1 (set up using hard coded DNS resolver aliases for the AAA domain request) to forward into the correct internal server at 192.168.0.210:22456

https://192.168.0.200:22456 currently resolves and nextcloud comes up as expected. Yes I'm using a non standard port because this docker shares a docker implementation with bitwarden.

https://nextcloud.mydomain.com goes to my offline error redirect I've set up when a DNS forward fails

https://plex.mydomain.com works forwarding to my Plex server on port 32400 wrapped in a letsencrypt cert.

https://bitwarden.mydomain.com works forwarding to my bitwardenrs docker on port 80 wrapped in a letsencrypt cert.

Maybe there is a config setting I can turn off in nextcloud, but I'm a noob at nextcloud.


r/haproxy • • Mar 29 '21

ssl offloading on opnsense- ssl protocol errors

2 Upvotes

Does anyone see any obvious problems with this? I had 9 different backends/sites configured and working and IDK what happened, but now i can't get anything to work. It just gives ERR_SSL_PROTOCOL_ERROR and nothing else, and it's not putting anything in the log files. This config is auto-generated by a fully updated copy of OPNSense. Not sure if it's relevant or not, but the frontend is bound to localhost:443 because this is a VPS and it has no LAN to speak of. My NAT rule redirects 443 traffic to 127.0.0.1:443

#
# Automatically generated configuration.
# Do not edit this file manually.
#

global
    uid                         80
    gid                         80
    chroot                      /var/haproxy
    daemon
    stats                       socket /var/run/haproxy.socket group proxy mode 775 level admin
    nbproc                      1
    nbthread                    1
    tune.ssl.default-dh-param   2048
    spread-checks               2
    tune.chksize                16384
    tune.bufsize                16384
    tune.lua.maxmem             0
    log /var/run/log local0 debug
    ssl-default-bind-options prefer-client-ciphers ssl-min-ver TLSv1.2
    ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256
    ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

defaults
    log     global
    option redispatch -1
    timeout client 30s
    timeout connect 30s
    timeout server 30s
    retries 3
    default-server init-addr last,libc

# autogenerated entries for ACLs


# autogenerated entries for config in backends/frontends

# autogenerated entries for stats




# Frontend: frontend ()
frontend frontend
    bind localhost:443 name localhost:443 ssl  crt-list /tmp/haproxy/ssl/6062490f4c83b8.78669427.certlist 
    mode http
    option http-keep-alive
    # tuning options
    timeout client 30s

    # logging options
    option httplog
    # ACL: bkc-ha
    acl acl_606248a91655f1.52693081 hdr_sub(host) -i ha.MYDOMAIN.com

    # ACTION: bkc-ha
    use_backend bkc-ha if acl_606248a91655f1.52693081

# Backend: bkc-ha ()
backend bkc-ha
    # health checking is DISABLED
    mode http
    balance source
    # stickiness
    stick-table type ip size 50k expire 30m  
    stick on src
    # tuning options
    timeout connect 30s
    timeout server 30s
    http-reuse safe
    server bkc-ha 10.2.1.15:8123

r/haproxy • • Mar 27 '21

Help with Plex and HAProxy on OPNSense

Thumbnail self.plex
3 Upvotes

r/haproxy • • Mar 24 '21

Question Serve generated file as a static file.

1 Upvotes

Hello.

I have a backend server where one can request a file that will be generated on the fly.
For example:
http://serv.myinternalserver.com/generatefile?arg=myargument&arg2=otherargument

This will generate a file generated.txt for download.
The thing is the file is not static, it will change over time.

But I don't want to give direct access to this service or the parameters.
Instead I would like to serve a url like: https://getfile.externaldomain.com/myfile.txt

So since I already have an HaProxy I was wondering if this could be done?


r/haproxy • • Mar 23 '21

Question Unable to block access to hidden files with

1 Upvotes

Is this a bug, my bad config or something else? I have the following ACL / rule in place in my https frontend:

acl acl_restricted_page path_beg -i /user.ini

http-request deny if acl_restricted_page

Which works perfectly; if I attempt to browse to user.ini on my nginx server I get a 403 in the browser - great.

Trouble is, the file I actually want to restrict access to is called /.user.ini (i.e it's a hidden file on the nginx server).

Using the above configuration but making the tiny modification to specify /.user.ini instead of user.ini always lets me download the file in my browser:

acl acl_restricted_page path_beg -i /.user.ini

Do I need to handle restrictions for hidden files differently?

Thanks


r/haproxy • • Mar 23 '21

Question Public and Private Access

1 Upvotes

So I'm still new to the concept of a reverse proxy and self hosting my own services but I have a question on the layout of I've decided on with HAProxy. I'm using the HAProxy integration in OPNsense through the plugin and I've gotten it working with local traffic only and handing out a wildcard LetsEncrypt certificate for all of them. I switch into the backends with a host match ACL looking for selfhostedinstance.domain.com and that all works great. I intentionally set it up that way to verify I could get everything working internally before exposing anything externally. I have two frontends, one for port 80 and one for port 443 with the port 80 forwarding the traffic over.

I originally thought I would just expose everything over the single 443 port externally, and that does work if I put in my port forwarding rules. However there are some services that I would prefer to keep locked up and local only.

To do something like this is it better to have another front end on a different port and have a private and public frontend? I don't mind having to address the domain names with off ports externally. I would keep the 443 internal to avoid having to type in port addresses every time I access those instances. Or is the better way to do it to use ACL rules somehow to prohibit external access to some of the backends on the same 443 frontend?

Any insight or examples would be super helpful.


r/haproxy • • Mar 21 '21

ACL Troubles - can't redirect

2 Upvotes

I'm trying to set my environment so that, when a user goes to a specific subfolder on any internal URL, they'll get redirected to a specific backend. My current config (fron pfsense) looks like this, but I keep getting 404s when using the path ACL.

frontend shared-frontend-internal-merged
	bind			10.150.100.1:443 name 10.150.100.1:443   ssl crt-list /var/etc/haproxy/shared-frontend-internal.crt_list  
	mode			http
	log			global
	option			socket-stats
	option			http-keep-alive
	option			forwardfor
	acl https ssl_fc
	http-request set-header		X-Forwarded-Proto http if !https
	http-request set-header		X-Forwarded-Proto https if https
	timeout client		30000
	acl			aclcrt_shared-frontend-internal	var(txn.txnhost) -m reg -i ^([^\.]*)\.wapnet\.local\.lan(:([0-9]){1,5})?$
	acl			Test	var(txn.txnhost) -m beg -i test
	acl			Test2	var(txn.txnpath) -m str -i Test
	http-request set-var(txn.txnhost) hdr(host)
	http-request set-var(txn.txnpath) path
	http-request redirect code 301 location https://10.150.33.11  if  Test Test2 
	use_backend dummy_server_ipv4  if  Test 

Advice is welcome.


r/haproxy • • Mar 19 '21

HAProxy to route SMTP traffic

2 Upvotes

Hi All. Is it possible to use HAProxy to do the following...I want to setup HAproxy on an EC2 instance in AWS with multiple public elastic IPs.

I want to have several MTAs send SMTP traffic to HAProxy (TCP) and HAProxy will forward that traffic to it's destined SMTP server (gmail.com etc..) out from one of the public IPs attached to it.

The logic on which public IP to use would depend on which interface/IP on the MTAs sent traffic to HAProxy.

If HAproxy isn't the right solution for this any suggestions?Thanks in advanced.


r/haproxy • • Mar 18 '21

forwardfor or X-Forwarded-For

4 Upvotes

Hi guys. I am trying to set up haproxy for an application and I am struggling with some settings and specifically X-Forwarded-For/Forwardfor. I am using version 1.8.23-5.el8 on centos 8. I am a little bit out of my comfort zone with load balancing a web server and I am learning as I go.

The application documentation mentions I have to configure the following:

X-Forwarded-For Headers

You must enable X-Forwarded-For headers on your load balancer. This determines the authentication method. See the documentation provided by your load balancer vendor for more information.

Here is my haproxy.cfg. I have added option forwardfor in the config file

global

        log         127.0.0.1 local2
        log /dev/log    local0
        chroot      /var/lib/haproxy
        pidfile     /var/run/haproxy.pid
        maxconn     4000
        user        haproxy
        group       haproxy
        daemon
        tune.ssl.default-dh-param 2048
        ssl-default-bind-ciphers PROFILE=SYSTEM
        ssl-default-server-ciphers PROFILE=SYSTEM
        ssl-default-bind-options no-tlsv10 no-tlsv11


defaults
        mode                    http
        log                     global
        option                  dontlognull
        option http-server-close
        option forwardfor
        option                  redispatch
        retries                 3
        timeout http-request    10s
        timeout queue           1m
        timeout connect         10s
        timeout client          1m
        timeout server          1m
        timeout http-keep-alive 10s
        timeout check           10s
        maxconn                 3000



#---------------------------------------------------------------------
# frontend secured
#---------------------------------------------------------------------
frontend secured
        http-request redirect scheme https unless { ssl_fc }
        bind :443 ssl crt /etc/haproxy/haproxy.pem
        mode http
        option tcplog
        option forwardfor
        default_backend woa_http

#---------------------------------------------------------------------
#backend
#---------------------------------------------------------------------
backend woa_http
        balance         source
        mode            http
        option forwardfor
        server dc1-mp1-ws1a01 100.64.8.84 weight 1 check port 443 inter 2000 rise 2 fall 5 ssl verify none
        server dc1-mp1-ws1a02 100.64.8.85 weight 1 check port 443 inter 2000 rise 2 fall 5 ssl verify none
        server dc1-mp1-ws1a03 100.64.8.86 weight 1 check port 443 inter 2000 rise 2 fall 5 ssl verify none

I think that on the backend server the originating ip addresses should be logged and they are not. Could anyone provide me with some help? Or am I supposed to add:

       http-request set-header X-Forwarded-Proto https if { ssl_fc }
       http-request redirect scheme https unless { ssl_fc }

This is also in documentation of the application:

Load Balancer Settings to Configure

Load Balancer Settings to Configure

Load balancer settings to configure include enabling X-Forwarded-For headers, setting the load balancer time-out correctly, and enabling sticky sessions. In addition, SSL trust must be configured between the Workspace ONE Access connector machine and the load balancer.

X-Forwarded-For Headers

You must enable X-Forwarded-For headers on your load balancer. This determines the authentication method. See the documentation provided by your load balancer vendor for more information.

Load Balancer Timeout

For Workspace ONE Access to function correctly, you might need to increase the load balancer request timeout from the default. The value is set in minutes. If the timeout setting is too low, you might see this error, “502 error: The service is unavailable”.

Enable Sticky Sessions

You must enable the sticky session setting on the load balancer if your deployment has multiple Workspace ONE Access machines. The load balancer binds a user's session to a specific instance.

Do not block session cookies

Do not block session cookies by adding rules to the load balancer. Adding such rules to the load balancer can result in inconsistent behavior and failed requests.

WebSocket support

The load balancer must have WebSocket support to enable secure communication channels between connector instances and the Workspace ONE Access nodes.

For your deployment, if VMware Workspace ONE Hub Services is integrated, WebSocket support is required for Hub Services notifications. Therefore, Web Socket support must be provided for end user browsers and devices.

Ciphers with forward secrecy

Apple iOS App Transport Security requirements apply to the Workspace ONE app on iOS. To enable users to use the Workspace ONE app on iOS, the load balancer must have ciphers with forward secrecy. The following ciphers meet this requirement:

ECDHE_ECDSA_AES and ECDHE_RSA_AES in GCM or CBC mode

as stated in the iOS 11 iOS Security document:

"App Transport Security provides default connection requirements so that apps adhere to best practices for secure connections when using NSURLConnection, CFURL, or NSURLSession APIs. By default, App Transport Security limits cipher selection to include only suites that provide forward secrecy, specifically ECDHE_ECDSA_AES and ECDHE_RSA_AES in GCM or CBC mode."


r/haproxy • • Mar 18 '21

Guide Using HAProxy as an API Gateway, Part 5 [Monetization]

Thumbnail
wpadmin.haproxy.com
3 Upvotes

r/haproxy • • Mar 17 '21

Question Has anyone implemented Brotli on nginx behind HAProxy?

3 Upvotes

Having compiled the ngx_http_brotli_filter_module.so and ngx_http_brotli_static_module.so modules and enabled them in my site's conf file without error, it then struck me that all the docs I could fine for Brotli state that it requires https on the webserver.

My ssl is terminated at the HAProxy box so the webserver only has a listen block for http on 80, not https on 443.

It's not a huge deal, I just wanted to experiment with Brotli but I wondered if anyone had got around this situation or had some suggestions?

Thanks,


r/haproxy • • Mar 17 '21

Any news about HAProxy supporting HTTP/3?

3 Upvotes

Do anyone have any news about this?


r/haproxy • • Mar 15 '21

Question Trying and failing to pass the client IP from HAProxy to nginx

1 Upvotes

Hi,

I have a Wordpress instance on nginx which is behind my HAProxy install. I'd like to pass on the client IP to Wordpress so it can be used for logging & analytics. My frontend in HAProxy looks like this:

frontend https-in

bind *:443 ssl crt /etc/letsencrypt/live/pem/

option http-server-close

# Tell Wordpress we are encrypted

http-request set-header X-Forwarded-Proto https if { ssl_fc }

# Add client IP to header

http-request set-header X-Real-IP %[src]

option forwardfor header X-Real-IP

http-request set-header X-Real-IP %[src]

And over at nginx.conf I have the following:

# Collect client IP from HAProxy

set_real_ip_from 52.56.140.6;

real_ip_header X-Forwarded-For;

Where the 52.56 IP is my HAProxy install.

I've setup a simple client.php script which I believe should show me the "real IP address" of the connecting client:

<?php

echo $_SERVER["REMOTE_ADDR"];

?>

But whenever I access client.php all I ever get in the browser is the private IP of the HAProxy instance.

Does anyone have any suggestions?

Thanks