Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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)?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.