0

I have an Apache based server running a number of sites along with the Virtualmin admin tool. I'd like to run HAproxy to direct one domain to a specific port (a Docker container) and everything else as usual (port 80) as there are several sites on this server.

Is this possible? Anyone got an example config I can work off please?

1

It's possible, but probably overkill for a single server. You can just create a ProxyPass directive in Apache for that domain.

<VirtualHost *:80>
  ServerName redirectedsite.example.com
  ProxyPreserveHost On
  ProxyPass / http://192.0.2.123:8080/
  ProxyPassReverse / http://192.0.2.123:8080/
</VirtualHost>

HAProxy is designed as a fast load balancer for redundant websites behind it. I suppose that it can be used as a proxy/redirection tool for multiple single sites, but why? Use the right tool for the job.

5
  • 1
    Thanks. I am installing Discourse in the Docker container and read that I should avoid mod_proxy/Apache completely meta.discourse.org/t/… – A4J Jun 2 '15 at 16:37
  • Ah, in that case, then go for it. I'd suggest nginx over HAproxy for this instance though, for the same reasons. – Hyppy Jun 2 '15 at 16:42
  • I already have Apache on this server - can nginx coexist with it? – A4J Jun 2 '15 at 16:52
  • Sure, they just can't use the same port. Make Apache port 8081 or something, and proxy everything through nginx – Hyppy Jun 2 '15 at 16:57
  • Thanks. I'm going to stick with HAproxy as the server is running Virtualimin and it doesn't play nice with both Apache and Nginx from what I've read. Thanks for your help :-) – A4J Jun 3 '15 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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