Running both Node.js and Apache on the same domain and "URL"

521 Views Asked by At

Is it possible to run Both node and Apache on the same domain without adding the port in the URL ? and serve both on the same page, i already have node running on port 8443 and Apache on port 433 and they both work fine but i need to specify in the link the port "8443" to access node which is not what i want, i want to serve both on the same URL if possible without adding the port to the URL.

2

There are 2 best solutions below

1
Harikrishnan On BEST ANSWER

You can use Apache reverse proxy

Add this configuration to your apache conf.

ProxyPass "/nodeapp" "http:/localhost:8443"

You can access node application by http://www.example.com/nodeapp

A reverse proxy is a type of proxy server that retrieves resources on behalf of a client from server. These resources are then returned to the client as if they originated from the web server itself.

0
drdr On

You can set an nginx proxy before them and separate routes to apache or node.

https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/