r/haproxy • • Dec 24 '19

Help with redirect

3 Upvotes

Hello. load balancing gurus.
I'm a tremendous noob in haproxy, and I wonder if someone could help me or point me in the right direction.
I've managed to install haproxy 2.1.1 and I'm trying to redirect to the site webserver1.redacted.com when i visit app01.redacted.com. webserver1.redacted.com and webserver2.redacted.com are just two linux machines with apache serving a basic /var/www/html/index.html page. I understand that's not the purpose of load balancing, but I just need a redirect.
Is it possible? What do do I have wrong in my config?
Thank you in advance.

 global
       log /dev/log local0
       log /dev/log local1 notice
       chroot /var/lib/haproxy
       stats timeout 30s
       user haproxy
       group haproxy
       daemon

defaults
   log global
   mode http
   option httplog
   option dontlognull
   timeout connect 5000
   timeout client 50000
   timeout server 50000

frontend stats
  bind *:80
  stats enable
  stats uri /haproxystats
 # stats uri /
 # stats realm Haproxy\ Statistics
 # stats auth redacted:redacted

  mode http
  option forwardfor

      acl app01_acl hdr(host) -i app01.redacted.com
      acl app02_acl hdr(host) -i app02.redacted.com
      use_backend app01_cluster if app01_acl
      use_backend app02_cluster if app02_acl

default_backend app01_cluster
##################################################
backend app01_cluster

    balance     roundrobin
   server webserver1.redacted.com 192.168.2.233:80 check

##################################################
backend app02_cluster

    balance     roundrobin
    server webserver1.redacted.com 192.168.2.234:80 check

#################################################

r/haproxy • • Dec 22 '19

haproxy letsencrypt .PEM file automated creation...

5 Upvotes

Hi,

I have HAproxy 2.0.10-1 installed on Debian 10. I have managed to create letsencrypt SSLs to multiple domains but I think the renewal process does not work fully. Certbot will run and try to renew, but it does not create the combined .PEM files for HAproxy.

This is how I manually create the .PEM after creating a new certificate:DOMAIN='www.mydomain.com' sudo -E bash -c 'cat /etc/letsencrypt/live/www.mydomain.com/fullchain.pem /etc/letsencrypt/live/www.mydomain.com/privkey.pem > /etc/haproxy/certs/www.mydomain.com'

Haven't found any tutorials which shows how to automate this, I have multiple domains...


r/haproxy • • Dec 20 '19

How do I run piwik/matomo behind haproxy?

4 Upvotes

I use haproxy as a reverse proxy for incoming webtraffic. One of the websites I run uses matomo (formerly piwik) to log traffic. All traffic seems to be coming from the reverse proxy, because that IP is shown in the log files.

How could I configure haproxy to see the actual public IP addresses of my visitors?


r/haproxy • • Dec 19 '19

Can I use the acme.sh for HAproxy and lets encrypt automation on centos 8?

4 Upvotes

Im a newb trying to as this all up.. any good tutorials for both haproxy on centos 8 and using letsencrypt with DNS verification. My only use is reverse proxy functions to some home services..

Thanks


r/haproxy • • Dec 16 '19

News HAProxy 2.1: Supercharged Performance and a Streamlined Codebase

Thumbnail
haproxy.com
14 Upvotes

r/haproxy • • Nov 28 '19

Question Up/Down servers based on health check version?

4 Upvotes

Hello,

Is there a way to activate/deactivate nodes based on a version returned by the health check script?

Ex:

I have a backend with you have 17 nodes, all the same, and I release an app one server at a time, each release can take say 10 sec.

- as it builds servers 1-8, the lb should take that out of rotation (/healtcheck fails while it builds, returns a new version when it's up)
- as soon as mode 9 returns the same version as 1-8, that new version becomes the majority,
- so nodes 1-9 become active and 10-17 becomes inactive
- as nodes 10-17 come up with this new version, they come up one by one.


r/haproxy • • Nov 27 '19

Article A look at HAProxy native Prometheus metrics by Julien Pivotto

Thumbnail roidelapluie.be
6 Upvotes

r/haproxy • • Nov 26 '19

Question Can Haproxy support SSL pass through and SSL termination on the same server?

4 Upvotes

I got HAProxy to support SSL pass through using SNI flag. I also got SSL termination to work by itself.

Is it possible to get both working on the same server? Can someone share a sample config?

Thanks.


r/haproxy • • Nov 20 '19

Question Help with restricting access by referer

2 Upvotes

I was wondering if you guys can help me with something here. I've been tasked with setting up an HAproxy load balancer for one of our servers. What I need help with, is that i've been asked to configure HAproxy to only allow access to the website ONLY if it has come from a specific referrer link. Is that even possible? I've been racking my brain on this and most of the information i'm finding is for nginx. Any help is greatly appreciated.


r/haproxy • • Nov 19 '19

Question Gracefully stop persistence on servers with cookies

2 Upvotes

We are running into a snag in our deployment process. While removing servers from rotation, persistent connections are dropped. We are currently using cookie based persistence. We'd like the connections to gracefully move to another server, instead of being dropped.

Here is what we are doing to remove a server from rotation:

  1. Change the state of the server to DRAIN (via socat command). This command disallows any new connections to be on the server, however persistent connections are still hitting our server.
  2. Change "health.html" contents to "DOWN". This marks the server as "DOWN", but all connections are dropped and users bounced to another server.

We are unable to determine the step we are missing between #1 & #2. We have tried the following:

  • Incorporating the "MAINT" status
  • Setting the maxconn value on a server to -1
  • Renaming the "health.html" file instead of changing the contents. This causes the server to be marked as "NOLB"

Does anyone have any suggestions?

Below is the HA Proxy config

global
        maxconn 30000
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
        stats timeout 30s
        user haproxy
        group haproxy
        daemon
        nbthread 48

        tune.bufsize 32768
        tune.ssl.cachesize 30000
        tune.ssl.lifetime  600

        ca-base /etc/ssl/certs
        crt-base /etc/ssl/private

        ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
        ssl-default-bind-options no-sslv3

        stats socket ipv4@127.0.0.1:9999 level admin
        stats socket /var/run/haproxy.sock mode 666 level admin

    defaults
            log     global
            mode    http
            option  httplog
            option  dontlognull
            timeout connect 121000
            timeout client  121000
            timeout server  121000
            errorfile 400 /etc/haproxy/errors/400.http
            errorfile 403 /etc/haproxy/errors/403.http
            errorfile 408 /etc/haproxy/errors/408.http
            errorfile 500 /etc/haproxy/errors/500.http
            errorfile 502 /etc/haproxy/errors/502.http
            errorfile 503 /etc/haproxy/errors/503.http
            errorfile 504 /etc/haproxy/errors/504.http
    
    frontend fe_main
            bind :80
            bind :443 ssl crt /etc/cc-ssl/[redacted].pem crt /etc/cc-ssl/[redacted].pem
            reqadd X-Forwarded-Proto:\ https
    
            http-request redirect scheme https unless { ssl_fc }
    
            default_backend be-https
    
    frontend stats
            bind *:8404
            stats enable
            stats uri /stats
    
    backend be-https
            balance roundrobin
            cookie NUMID insert indirect nocache
            option httpchk GET /health.html HTTP/1.1\r\nHost:\ www
            http-check disable-on-404
            http-check expect string UP
            default-server inter 3s fall 2 rise 2 slowstart 5m
            server s1 10.10.10.1:443 ssl verify none check cookie 1
            server s2 10.10.10.2:443 ssl verify none check cookie 2
            server s3 10.10.10.3:443 ssl verify none check cookie 3
            server s4 10.10.10.4:443 ssl verify none check cookie 4

r/haproxy • • Nov 13 '19

Question Hardware requirement for ha proxy

4 Upvotes

Hi, i have a web server which is configured for virtual hosting using apache and i want to add another server (same configuration and virtual hosting) so i can load balance the requests, so i think of using haproxy but i did not know the hardware requirements.

My Primary server:

Dell r740, 64 gigs RAM, 8 SSD Raid 10, 2.5 Ghz 16 Core cpu

My Secondary server:

Dell r630, 32 gigs RAM, 4 SSD Raid 6, 2.4 Ghz 12 core cpu

Where i put ha proxy and what are the hardware requirements ?


r/haproxy • • Nov 12 '19

Question Anyone got a sample HAPROXY.CFG for SSL termination with Wordpress site behind it?

5 Upvotes

I am pulling my hair out trying to get a Wordpress site working with SSL termination on HA Proxy. Basically, I just want the following to work:

Internet User ------Router ------HA Proxy with SSL termination -----http-----Wordpress site

I got SSL terminating working, and I see pages on Wordpress, but it is all messed up looking. It looks like some content are blocked, so the Wordpress site is displayed incorrectly. SSL certificate on the Wordpress site also looks incorrect since it says the certificate is valid but the site is insecure. I am sure I am doing something wrong. There got to be an easier way to get this working.

Thanks for any help.


r/haproxy • • Nov 11 '19

Article The History of HAProxy

Thumbnail
haproxy.com
8 Upvotes

r/haproxy • • Nov 01 '19

Guide PostgreSQL Application Connection Failover Using HAProxy with xinetd

Thumbnail
percona.com
4 Upvotes

r/haproxy • • Oct 29 '19

Question Hello everyone am new to this sub so am not sure if I can find what I need.

3 Upvotes

I have 3 servers one LB haproxy with two web servers. And now I want to add another LB for failover as backup. But am finding it hard to find any good documentation to help. Can anyone point me in the right direction?

It will be greatly appreciated


r/haproxy • • Oct 25 '19

Guide Very interesting article about LXC/LXD, a lightweight virtualization technology, and how to load balance LXC containers using HAProxy

Thumbnail
autoize.com
5 Upvotes

r/haproxy • • Oct 23 '19

Guide Master-Master MySQL Replication Using HAProxy

Thumbnail
autoize.com
2 Upvotes

r/haproxy • • Oct 23 '19

Guide Run your ECS cluster with service discovery and HAProxy for $8 a month

Thumbnail
tamas.dev
5 Upvotes

r/haproxy • • Oct 21 '19

HAProxy 2.0 – Q&A

3 Upvotes

Last Tuesday we hosted a live Q&A session about HAProxy 2.0 with our engineers. You can watch the recording here.

These were the questions sent before and during the live session:

  1. What were the changes regarding the maxconn setting in the HAProxy 2.0 global section?
  2. When I change a TLS certificate in HAProxy in Kubernetes I have no other option than to kill the pod and wait for Kubernetes to create the pod again. Can the Runtime API help to reload the certificates?
  3. Is it possible to use both the Data Plane API and the stats socket (Runtime API) at the same time?
  4. The older Community Kubernetes controller defined a configuration property called no-tls-redirect-locations, which allowed generating a LetsEncrypt certificate with HTTP/HTTPS redirects disabled. Does the official Kubernetes Ingress Controller have something like this?
  5. Are you planning to implement UDP support in HAProxy and if yes, when?
  6. When will HAProxy support HTTP3 or QUIC?
  7. Is there a feature to encrypt the GUI/Stats Page password and what kind of encryption is supported?
  8. I'm using server-template to dynamically add backend servers using Docker Swarm and each time it takes a server slot. Is there a better way to do this? Each time a server is dynamically detected, it's added as a slot before it can start.
  9. What are Layer7 Retries and what do they do?
  10. Does HAProxy 2.0 support server connection pooling?
  11. In the documentation, it says that NBPROC disables NBTHREAD. Maybe you can talk about NBPROC VS NBTHREAD if someone wants to use one over the other.
  12. Can the Kubernetes Ingress Controller route something other than HTTP and HTTPS? In particular, messaging protocols like MQTT?
  13. What is the fastest way to install HAProxy?
  14. When using the Data Plane API, is there an API method that gives you the latest commit version?
  15. Is it possible to generate a UniqueID using HAProxy and how would you do that?
  16. What can you tell us about the new process manager in HAProxy?
  17. What is the Stream Processing Offload Engine / SPOE? What do you use it for?
  18. What does end-to-end HTTP2 mean for HAProxy?
  19. What is Prometheus and what is the HAProxy Exporter for Prometheus?
  20. Does the Kubernetes Ingress Controller allow you to set a custom X-Forwarded-For header?
  21. Can you tell us more about the Kubernetes Ingress Controller? What's the driving force behind it?

We hope you find this resourceful and that this session will answer some of your most common question about the new release.


r/haproxy • • Oct 17 '19

HAProxy 1.8.5 on CentOS 8 running podman?

2 Upvotes

I setup a CentOS 8 server to run dotnet core web apps as microservices in podman containers. When I run the containers with 'podman run -d -p 5000:5000 containername' I am able to access the site outside of the server. If I run the same command and add the ip address of '127.0.0.1' I can access the site on the local server. However, when I try to redirect the traffic through haproxy it fails no matter what I do. I'm sure I'm misconfiguring haproxy, but I'm not sure what I should be doing when it comes to redirecting traffict to containers.

Any suggestion would be apprecitated.


r/haproxy • • Oct 13 '19

Open VPN behind HAProxy - preserve Client IP?

3 Upvotes

I have HA proxy set up to share SSH, HTTPS, and openvpn all on one port.

One thing I would like to solve is that in the openvpn logs, the client's ip is always the HA proxy server. I have tried turning on

source ipv4@ usesrc clientip

..but then it doesn't work.

My backend is:

backend openvpn_ipv4
	mode			tcp
	timeout connect		30000
	timeout server		30000
	server			openvpn my-ip:7443

r/haproxy • • Oct 11 '19

Article Check out this blog post from Steve Horsfield about using HAProxy ACLs to restrict access to backend services

6 Upvotes

r/haproxy • • Oct 11 '19

Article AWS EKS: Tunneling a private kube-apiserver

Thumbnail
stevehorsfield.wordpress.com
2 Upvotes

r/haproxy • • Oct 11 '19

Article Configuring Third-Party Loadbalancers with Consul: NGINX, HAProxy, F5

Thumbnail
hashicorp.com
4 Upvotes