SSL and Domain resolution question

0

Hello, thanks ahead of time for reading this!

--

I have a domain I purchased (deepdungeonoverlay.com).

I have an SSL certificate created for deepdungeonoverlay.com as well as www.deepdungeonoverlay.com and dev.deepdungeonoverlay.com

I have an EC2 instance with apache installed and my very simple content uploaded to var/www/html

I have an elastic IP set up and configured to point to this EC2 instance.

I have a CloudFront distribution currently configured for both deepdungeonoverlay.com and www.deepdungeonoverlay.com with the appropriate SSL certificate selected and pointed to the public ipv4 DNS.

I have Route 53 Alias records set up for both deepdungeonoverlay.com and www.deepdungeonoverlay.com that point to the appropriate CloudFront distribution.

--

Going to the root of deepdungeonoverlay.com or www.deepdungeonoverlay.com both properly resolve and my index.html file is displayed, and the SSL certificate is properly applied.

However, if I try to visit deepdungeonoverlay.com/target info, which is a sub folder with its own index.html file in it, the connection becomes not secure, and the URL no longer displays deepdungeonoverlay.com but instead reads the public ipv4 DNS URL with /targetinfo after it. The html file displays correctly.

My expected behavior is that all content served from my EC2 instance would be under the proper URL and have the SSL certificate applied.

I have been trying to understand what is going on for two days. Countless web articles and YouTube videos on setting up EC2 websites with AWS SSL and Route 53 and I cannot see where I am going wrong or what setting I am missing.

If it wasn't obvious, I am not a DevOps professional, so this has all been a learning process for me.

Any and all help or recommendations appreciated!

Thanks

Lokken

2 Answers
0
Accepted Answer

Try forwarding host header to origin in your cloudfront distribution

https://stackoverflow.com/questions/68876033/apache-redirecting-example-com-to-ec2-public-dns

answered a year ago
  • So this appears to have worked but only for the www.deepdungeonoverlay.com domain, it has not worked for deepdungeonoverlay.com even though I made the same update to both distributions

  • I ended up finding it ridiculous I had two distributions for the same domain so I kept a single distribution for both deepdungeonoverlay.com and www.deepdungeonoverlay.com and listed them both as CNAMEs in the alternate domain names setting and just set both A records in Route 53 to go to the same distribution. I have that single distribution forwarding the HOST header as described above and it appears to be working.

    Thanks for the help!

0

The problem is occurring because your webserver is issuing a redirect:

GET https://deepdungeonoverlay.com/targetinfo

HTTP/2 301 Moved Permanently
content-type: text/html; charset=iso-8859-1
content-length: 267
location: http://ec2-54-91-190-28.compute-1.amazonaws.com/targetinfo/
date: Wed, 18 Jan 2023 09:39:26 GMT
server: Apache/2.4.54 () OpenSSL/1.0.2k-fips
x-cache: Miss from cloudfront
via: 1.1 b9061e936b29505d1b542db7af99b46c.cloudfront.net (CloudFront)
x-amz-cf-pop: LHR61-C2
x-amz-cf-id: TJkYZFqX1vFlXXhG6KpNLHj2_GLatCCaqOMPHV6cGitwfUbetnWyCQ==
X-Firefox-Spdy: h2

You will need to adjust your webserver configuration to remove the redirect in order to solve the problem.

AWS
EXPERT
Paul_L
answered a year ago
  • Thank you for the answer!

    So I've spent a couple hours looking around at Apache redirect articles and videos. My issue is I cannot find anything in my server's config where a redirect is happening. I can find resources on how to add a redirect (in this case I assume by adding this stuff to the httpd.conf file but my current httpd.conf file is very sparse and has no redirect).

    I have a very bare bones EC2 instance, the only thing I have installed is httpd and copied my content up to var/www/html/

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions