My setup used to be Apache serving some php sites on different sub-domains, like this blog running on WordPress and a little photo-album.

When I started hosting node.js apps, I just put them on different ports. So I would share links like “Check out Pathfinder at sam-the-man.com:3000“… which frankly doesn’t really represent the modern web very well, especially as a web-developer. What I really wanted was to put these apps onto different subdomains, but I didn’t want Apache to serve them, since node.js is perfectly capable of serving web applications.

I’m trying out HAProxy, which seems to do the job well so far.
I have HAProxy listening at port 80, and redirecting traffic to the node.js app mentioned above at the subdomain pathfinder.sam-the-man.com, and all other traffic currently gets sent to Apache which is listening on a different port. And Apache is still handling subdomains as well.

Here are the relevant parts of the HAProxy config file:

frontend http-farm
  bind *:80
  mode  http
  option httplog
  acl apache hdr(host) -m beg www.
  acl pathfinder hdr(host) -m beg pathfinder.
  use_backend apache_be if apache
  use_backend pf_be if pathfinder
  default_backend apache_be

backend apache_be
  mode http
  server apache 127.0.0.1:9000

backend pf_be
  mode http
  server pathfinder 127.0.0.1:3000

So in the configuration file you have to define a “frontend”, which is the part that listens on a port and accepts requests, as well as routes those requests to the “backends”.

  acl apache hdr(host) -m beg www.
  acl pathfinder hdr(host) -m beg pathfinder.

As you can see, we define a few rules in the frontend, with the acl keyword. The apache rule looks for anything beginning with “www.” and the pathfinder rules looks for anything beginning with “pathfinder.”

  use_backend apache_be if apache
  use_backend pf_be if pathfinder
  default_backend apache_be

We then tell it to use the defined backend “apache_be” if the acl rule “apache” is true, or the “pf_be” backend if the “pathfinder” rule applies.
If neither of them apply, we use the “default_backend” as a catch all.
There are of course a lot more options that HAProxy (documentation) provides, this is just how I decided to initially set it up.

Subdomains with HAProxy for Node.js and PHP apps

Leave a Reply

Your email address will not be published. Required fields are marked *

tamil office sex videos erosexus.info sunny leone sex photo sloutload xxx-tube-list.info vice city india aunty milf megeno.mobi materbation grandma sex video tubanator.mobi ellalive dragon xxx hentaieva.com monkey hentai تحرش ونيك green-tube.net بنات تنيك بعضها 超激カワゆうちゃんが18歳の時の流出動画!オナニー編 javvideos.net 月山なのは nudist beach ni syuugaku besthentaisex.com final fantasy 12 hentai probinsyano april 1 2022 pinoyteleseryeonline.com huwag kang mangamba october 29 2021 full episode 3gp xvideos download pornorgy.org heroine bf video rajisha vijayan xxx 3gpjizz.mobi sexy video indin mano po legacy time slot teleseryeshd.com ika 6 na utos september 15 hentai big boobs hentaimol.com pokemon hantia punjabi sexy kand video threesomeporntrends.com indian xxx garl ang probinsyano jan 20 2022 wowteleserye.com mainit na balita