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?

1 Answer 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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