kevinzf
kevinzf

Reputation: 193

Hosting two web server instances on the same machine

I am developmening a website and want to use two web frameworks(Flask and wordpress). I am wondering if it is possible to have one machine hosting two web frameworks.

If yes, I am confused about the port. If they all listen to port 80, how can they know which server should serve the url?

For example, assume there are two url:

www.myDomain.com/page1   I want it goes to Wordpress
www.myDomain.com/page2   I want it goes to Flask

I did some search but didn't find a definite solution. Can I get some helps to do this?

Upvotes: 0

Views: 380

Answers (1)

Simon Travancas
Simon Travancas

Reputation: 81

Yes, you can do that. What you want is called a reverse proxy. According to wikipedia, one of its uses is:

Reverse proxies can operate wherever multiple web-servers must be accessible via a single public IP address. The web servers listen on different ports in the same machine, with the same local IP address or, possibly, on different machines with different local IP addresses. The reverse proxy analyzes each incoming request and delivers it to the right server within the local area network.

So you would want something like:

Server A running on port 3000

Server B running on port 3001

Reverse proxy listening to port 80 (and/or 443 for https) and redirecting traffic to either port 3000 or 3001, as appropriate

Examples of services that provide reverse proxies are Nginx and Apache (among others).

Upvotes: 1

Related Questions