DNS Redirect – Redirecting a Subdomain to a Different IP

amazon-web-servicesdomain-name-systemredirect

This question was originally posted on the Network Engineering StackExchange page, but has been moved here.

TL;DR I have a domain name attached to an AWS Elastic IP, I'd like to create a record for a subdomain that redirects to a completely different IP.

Hello, currently I'm making a website as a personal project. My setup is currently an AWS EC2 instance running RHEL, with an elastic IP associated with it. At the moment, I just have apache HTTPd installed with a proof-of-concept index.html (eventually plan to switch to Tomcat).

I've also registered a domain name via AWS Route 53, and successfully created a record for the main website. I.e, navigating to my domain correctly shows my website. Now, unrelated to the AWS services, I host a PLEX server on my own network (PLEX is media server). You can access this PLEX server directly by navigating to my own personal IP address (not recommended, but for testing purposes at the moment). I've modified my router's firewall to redirect all incoming data from port 80 to the specific PLEX port I have. In other words, by navigating to my IP directly in a browser, the PLEX server loads up.

When I try to create a record for a subdomain (in my example, the subdomain would be watch.mydomain.name, where watch is the subdomain), the page never loads (Connection timed out). I don't think it's an issue with the PLEX server, but rather how my EC2 is handling redirects. I'm curious if SSL is at play as well, since when trying to navigate to the subdomain, it automatically attempts https. Note, the main website does have a certificate, though it's self signed. This means the main domain can be connected with https. I tried creating an A record, similar to the one for my EC2 IP, but with my personal IP. I've tried various ports, but redirecting 80 -> the plex port seems to make the most sense. I'm at a lost for solutions, and not sure who/where these possible errors would be logged.

Thank you for any advice or solutions. Please let me know if you need any more information.

Best Answer

If Route53 manages your domain, just create an A record pointing to your IP. It will all work as intended.

Example:

screenshot of example

EDIT: Apologies - I missed your last paragraph. Creating an A record should definitely work, although you might need time for your DNS cache to update. If it's not working then you need to debug the various links in the chain, from resolving DNS on your client, to the local router, to the server, iptables, etc etc.

You'll need to explicitly set HTTP in your browser to use it nowadays as most seem to assume HTTPS. If that works with your route forwarding port 80 to the Plex server, then you can attempt to add HTTPS in to the mix. I'd recommend not logging in via HTTP though ;-)

Related Topic