Search code examples
http-redirectamazon-ec2webfaction

Redirecting a subdomain to AWS instance


I have a domain example.com that is being host on webfaction. However i would like to redirect its subdomain (e.g sub.example.com) to one of my AWS instance which has public DNS of:

https://ec2-xx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com:8083 (please note the port number).

This instance is then assigned with elastic IP address.

So far, the solution that i tried is:

  1. Using CNAME redirection, however it does not work because of this: https://forums.aws.amazon.com/thread.jspa?threadID=55995

  2. Then i proceed to use the old fashion .htaccess:

    Redirect permanent / http://ec2-xx-xx-x-xxx.compute-1.amazonaws.com order deny,allow

    However, i want to keep the sub.example.com on the address bar instead of changing it AWS public dns.

Does anyone know what is the best way to solve this? Thanks


Solution

  • If you have assigned an elastic ip to the instance, you should be able to just setup a new 'A' record in your DNS that points directly to that IP address, no?

    The listening on the specific port should be handled by the bindings on the instance (either thru apache or IIS)