João Gomes
João Gomes

Reputation: 332

How to connect to RabbitMQ behind a Nginx reverse proxy using AMQP protocol

I have a client application built with C# that communicates with RabbitMQ using AMQP but since the message broker was moved behind a Nginx reverse proxy it stopped working. How can i configure Nginx to work with AMQP and if is not possible which alternatives do i have?

Upvotes: 0

Views: 3432

Answers (1)

CamW
CamW

Reputation: 3363

Nginx can be configured to load balance TCP and UDP so you could configure nginx for tcp load balancing and use it in a similar way to if you were proxying HTTP. Link to documentation here: https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/

Example config:

stream {
    upstream stream_backend {
        least_conn;
        server backend1.example.com:12345 weight=5;
        server backend2.example.com:12345 max_fails=2 fail_timeout=30s;
        server backend3.example.com:12345 max_conns=3;
    }

    server {
        listen        12345;
        proxy_pass    stream_backend;
        proxy_timeout 3s;
        proxy_connect_timeout 1s;
    }

    server {
        listen     12346;
        proxy_pass backend4.example.com:12346;
    }
}

Upvotes: 0

Related Questions