Thursday, January 27, 2011

Can a server run both haproxy and nginx? How would they both work?

Can a single server run both haproxy and nginx at the same time?

I guess I would have to run nginx on a different port, and then route specific traffic to nginx?

Say I have 2 domains, 1 requires nginx and the other requires another service.

Can haproxy send requests for domain#1 to nginx? and domain#2 to another server?

  • Yes you can, in fact this was what stackoverflow was doing for a while. Basically you pick one to be in front of the other. The one in front would be on port 80 and the one behind it will be on some random port of your choosing. You would just treat the second load balancer as if it was a web server behind the load balancer. Just keep in mind you will probably want to enable the X-Forwarded-For feature so you actually see the client IPs.

    If you want them both to be on port 80 and not be in front of each other than you can bind them each to a specific IP address.

    See this post for a similar situation: Nginx (for static files) and Apache (for dynamic content)?

0 comments:

Post a Comment