Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Route a specific path to a specific EC2 instance using Route 53

I'm not sure if this is even possible, but if so I'm looking for the best way to do it.

Say I want to host my blog for example.com on it's own EC2 instance, and I want the path to my blog to be example.com/blog

Is it possible to route all requests to example.com/blog/* to one instance, and all other requests to that domain elsewhere?

My web server is Apache.

Thanks!

like image 370
Sherms Avatar asked Apr 10 '14 16:04

Sherms


3 Answers

You can now do this with Application Load Balancer and path-based routing: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/tutorial-application-load-balancer-cli.html#path-based-routing-aws-cli

like image 145
yurez Avatar answered Nov 03 '22 19:11

yurez


Certainly it's possible, but not with DNS nor with an ELB. The most common solution to this is to use a web server that issues a 301 or 302 redirect.

In your case, example.com would point to whatever the main site is. The web server (nginx or Apache httpd, perhaps) hosting example.com would have a redirect for example.com/blog/* that is found at another destination.

Here's an SO post on using Nginx for a redirect and for using Apache for a redirect.

like image 23
Ben Whaley Avatar answered Nov 03 '22 21:11

Ben Whaley


Yes, but you would have to proxy your requests through an instance handling example.com. How you configure this depends on your web server.

Some examples on how to configure this:

  • nginx: http://wiki.nginx.org/HttpProxyModule
  • Apache: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
like image 35
datasage Avatar answered Nov 03 '22 21:11

datasage