0

I have an ec2 machine running nginx. It has a lot of projects and typically I access it via:

https://ai.mydomain.com/myproject

One of these projects is spinning out to be separate. Assuming the ip was xxx.yyy.aaa.bbb, how would I get the godaddy to point there?

Specifically how would I get http://myproject.com to point to -> xxx.yyy.aaa.bbb/myproject

Also, if I have a letsencrypt cert for https://ai.mydomain.com, how would I have two certs on the machine for different domains?

2 Answers 2

0

Assuming by godaddy you mean the dns service this is not possible, because it is simply not part of the dns protocol and would not make sense at that level in the stack.

What you want is a reverse proxy or cdn. A reverse proxy makes the request on behalf of you, and have additional features like rewriting the request path, or contacting multiple origins based on some rules. All this is possible because it operates on the http(s) level but hides the origin servers as an implementation detail.

One such cdn is amazon cloudfront. There it is possible to specify origin path which cloudfront will then append to all requests.

Considering you have tagget the question with lets-encrypts i want to note that is not needed with aws cloudfront. AWS can generate a certificate for you to use with the cloudfront. This is quite cheap in the order of a few cents/month unless you have much traffic.

Here is the configuration where you need to specify origin path: enter image description here

0

In case this helps someone in the future, I solved this using nginx:

Specifically:

  1. have your dns point both domains to the same ip of your server
  2. set up two nginx server blocks: one for domain1.com and a second for domain2.com. Those server blocks should point to different locations for their root folders.
  3. if youre running react, angular, etc on some port (eg 3000), have the second sever block proxypass everything to that port either through the default / location or some custom location.

I loosely followed this article:

https://ubiq.co/tech-blog/configure-multiple-host-names-nginx/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .