1

I currently have a web server running apache with multiple sites on it using virtual hosts. I want to add a service to my server that is using nodejs but I want it to be accessible under the same domain as a sub-domain. This is, I believe, impossible with my current setup since nodejs and apache can't both listen on port 80 simultaneously, so I suppose I must run some proxy service on port 80 and then split my requests between the two servers based on the Host request header.

I have a few questions regarding this matter:

  • Are my above assumptions correct?
  • Is such a proxy setup costly in terms of performance?
  • What would be the best suited software to serve as the proxy? Is it best to stick with a server implementation (such as apache or nginx) for the proxy software or would a simple tcp server script perform better since it would be designed especially for this matter?
php_nub_qq
  • 2,204
  • 4
  • 17
  • 25

1 Answers1

1

As you have described the problem, yes your assumptions are correct.

Both NGINX and Apache are built to do this in a very performant way. mod_proxy in Apache or proxy_pass in NGINX are likely to be much easier and perform far better than any custom proxy you might write. The only reason I can think of not to use them is if your logic for selecting the backend service is more complex than they are built for. Just having a subdomain as the selection criteria is trivial to either.

Paul
  • 3,277
  • 1
  • 17
  • 16