Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4731

Switch from NGINX to HAProxy

$
0
0

I am trying to change load balancing, which I am using, the main purpose I need this for using Docker Swarm’s DNSRR endpoint mode which nginx cannot resolve.

I’ve such nginx config:

server {

    listen 8080;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # To forward the original client's IP address
    proxy_set_header X-Forwarded-Proto $scheme; # to forward the  original protocol (HTTP or HTTPS)
    proxy_set_header Host $http_host; # to forward the original host requested by the client
    proxy_set_header X-Real-IP $remote_addr;


    location /swagger/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;

        proxy_pass http://swagger-merger/;
    }
    
    location /rabbitmq/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
    
        proxy_pass http://rabbitmq:15672/;
    }

    location /companies/ {
        proxy_http_version 1.1;

        proxy_pass http://companies-api/;
    }

    location /links/ {
        proxy_http_version 1.1;

        proxy_pass http://links-api/;
    }

    location /news/ {
        proxy_http_version 1.1;

        proxy_pass http://news-api/;
    }

    location /importstructure/ {
        proxy_http_version 1.1;

        proxy_pass http://import-structure-api/;
    }

    location /structure/ {
        proxy_http_version 1.1;

        proxy_pass http://structure-api/;
    }

    location /profile/ {
        proxy_http_version 1.1;

        proxy_pass http://profile-api/;
    }

    location /registration/ {
        proxy_http_version 1.1;

        proxy_pass http://registration-api/;
    }

    location /files/ {
        proxy_http_version 1.1;

        proxy_pass http://files-api/;
    }
}

What I need to make the same settings with HAProxy config. What is nginx’s location directive analogue in HAProxy? My HAProxy config:

global
    log          fd@2 local2
    chroot       /var/lib/haproxy
    pidfile      /var/run/haproxy.pid
    maxconn      4000
    user         haproxy
    group        haproxy
    stats socket /var/lib/haproxy/stats expose-fd listeners
    master-worker

resolvers docker
    nameserver dns1 127.0.0.11:53
    resolve_retries 3
    timeout resolve 1s
    timeout retry   1s
    hold other      10s
    hold refused    10s
    hold nx         10s
    hold timeout    10s
    hold valid      10s
    hold obsolete   10s

defaults
    timeout connect 10s
    timeout client 30s
    timeout server 30s
    log global
    mode http
    option httplog

backend swagger
    balance leastconn
    option httpchk
    retry-on all-retryable-errors
    retries 2
    server-template swagger-merger- 1 http://swagger-merger check resolvers docker init-addr libc,none

backend stat
    stats enable
    stats refresh 15s
    stats show-legends
    stats show-node

Is that right setup for backend “swagger-merger” which is first in nginx? Or did I miss something? I just need help with one, other I’ll do with analogue.

Thanks in advance for any help!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4731

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>