I know that this is a common question, and there are answers for the same, but the reason I ask this question is because I do not know how to approach the solution. Depending on the way I decide to do it, the solution I can pick changes. Anyways,
I have an AWS EC2 instance. My DNS is handled by Route53 and I own example.com. Currently, on my instance, there are two services running:
example.com:80 [nginx/php/wordpress]
example.com:8142 [flask]
What I want to do is, make app.example.com
point to example.com:8142
. How exactly do I go about doing this? I am pretty sure that I will have to point app.example.com
to the same IP as example.com
, since it is the same box that will be serving it. And, nginx will be the first one to handle these requests at port 80. Is there a way with which I can make nginx forward all requests to localhost:8142?
Is there a better way that I can solve this problem?
You could add a virtual host for app.example.com that listens on port 80 then proxy pass all requests to flask:
This is how you would do it with apache.