https://example.com is not accessable (unable to redirect from godaddy) when implemented with AWS - aws-application-load-balancer

I have tried adding subdomains in CNAME record anthose are working fine (from AWS we have server endpoint instead of ip) but the format http://example.com is not accessable anyway. Tried through .htaccess file as well. Please help to resolve the issue.

Related

Apache redirecting example.com to ec2 public DNS

Setup
Route 53 Domain example.com has A record to id.cloudfront.net and AAAA record to random-id.cloudfront.net.
Cloudfront has origin domain as EC2 public DNS ec.xxxxxx.amazonaws.com and alternate domain as example.com. Also, it has a AWS certificate for SSL/TLS (for now it accepts both HTTP & HTTPS requests)
EC2 is an Ubuntu-20.04 AMI with apache2, php7.4 and phpmyadmin, all installed using apt-get.
Issue is whenever I put in example.com/* the site is automatically redirected to ec.xxxxxx.amazonaws.com/*.
Example:
example.com/phpmyadmin gets redirected to ec.xxxxxx.amazonaws.com/phpmyadmin/.
I tried to setup wordpress and example.com redirects to http://ec2-xxxxxx.amazonaws.com/wp-admin/setup-config.php`
These are the things I have tried.
Added ServerName example.com in /etc/apache2/apache2.conf
This command sudo ufw allow in "Apache Full"
I do not have .htaccess in my /var/www/html folder.
Is it a Cloudfront or an Apache issue? This is my first rodeo with AWS and Apache and trying to learn how it works.
Solutions that seem out of scope:
https://serverfault.com/questions/685654/apache-server-config-redirect-from-ip-to-domain-name-ec2
Or anything that includes creating .htaccess at the root directory as I feel that would create an endless loop.
I can provide more information, if required.
Update:
Removed A and AAAA record from route53. Doesn't work.
Also, added ServerName example.com to /etc/apache2/sites-enabled/000-default.conf
Also, visiting random-id.cloudfront.net does the same redirection.
However, visiting elastic-IP does not do any redirection.
If I correctly understand your setup, probably you need CNAME instead of A record in Route53
Traced the issue to HTTP_HOST being the ec2 public DNS received by the server. So, if I visited example.com/index.php and the code were supposed to redirect to example.com/index2.php it would instead redirect to ec.xxxxxx.amazonaws.com/index2.php because HTTP_HOST = ec.xxxxxx.amazonaws.com.
Fixed by updating CloudFront Distribution's behavior to forward Host value.
So, if I visit example.com the host value would be example.com
And if I visit id.cloudfront.net then host value would be id.cloudfront.net.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23

Why is my IONOS 1&1 root not redirecting correctly over ssl?

I have a 1&1 IONOS domain for my heroku app. the www subdomain works fine, with a CNAME setup for it. but I'm trying to redirect the root url to the www subdomain. this also works fine for http, but if the url is typed in as https://example.com, I get a ERR_SSL_PROTOCOL_ERROR (on chrome, other browsers have different errors). this is on any device, regardless of clearing cache and history etc.
my heroku logs show it's never reached, so it must be an issue within 1&1.
theres an ssl cert set on the domain with 1and1, as well as heroku's ACM.
any ideas?
To make the four URL variations (http://example.com, http://www.example.com, https://example.com, and https://www.example.com) point to a different SSL hosted site (heroku, cloudfront, etc), you need three things in IONOS:
Under DNS settings, add a CNAME entry for the www subdomain that points to your SSL hosted site (example.herokuapp.com)
Set up an HTTP Redirect under Domain Forwarding to https://www.example.com (don't check the box that states "Also set up for www subdomain")
Make sure you have an SSL wildcard certificate for *.example.com installed and attached to your domain in IONOS
It looks like all you are missing is number 3. After that, the redirect that you have setup should work as expected.
Note: example.com should be replaced by your actual domain in all of the above.

Redirection from www to https

I have a subdomain called for example : hello.example.com.
I can access this url using hello.example.com or https://hello.example.com.
The problem is that some of our customers use www.hello.example.com which doesnt show the website.I tried multiple redirection methods. But none is working perfectly.
Our environment : The website is hosted in 4 aws instances with 2 haproxy load balancers(total 6 instances). The domain is routed in aws Route 53.
I Tried 3 methods:
1. Adding a redirect rule in haproxy.cfg file "redirect prefix hello.example.com code 301 if { hdr(host) -i www.hello.example.com }"
Adding rewrite rule in .htaccess file in my document root
By adding www.hello.example.com in route53 ad route it to a s3 bucket with same name and using static website hosting to redirect it to hello.example.com
I am getting ssl certificate error while using the 1st method. I think this has something to do with the url being a subdomain.I have wildcard certificate for *.example.com . So this doesnt work for www.hello.example.com
The second method doesnt do anything.
And with third method i sometimes get the website using www, but not always. If i clear my cache and then search for it i will git using www, but only for 1 time.

Namecheap domain won't redirect without "www"

I'm looking to connect my domain to a heroku app. So far, the tutorials I've read say we want Namecheap to have the following records for domain example.com:
CNAME Record www www.example.com.herokudns.com
URL Redirect # https://www.example.com
With this config, I can successfully get to my homepage using:
http://example.com/
http://www.example.com/
https://www.example.com/
But for some reason https://example.com/ won't connect and times out. Does anyone know if there's a way to get both https://example.com/ and https://www.example.com/ to redirect successfully?
You won't be able to do this with DNS provided redirects.
The reason is that at the point of redirect, ie your DNS provider they would need to:
Accept https/443 requests to their redirector
have a valid certificate for hacksofcharity.com
if they don't you'll either receive a timeout, or a certificate mismatch in your browser. When apex domains are involved with https then your only option is to be using a DNS provider that supports using CNAME - see https://devcenter.heroku.com/articles/custom-domains#add-a-custom-root-domain and perform any redirects within your application code base.

Subdomain redirect when using HTTPS

My website runs on WooCommerce in public_html. I have a Subdomain in a public_html/sub. When I try to access the sub using HTTPS it seems to redirect to /wp-admin. I'm using the default URL rewrites that come with WooCommerce. How can I fix this issue?
Look at the Apache Config / Vhosts etc.
Basically, search for *:443 in the configuration file (or [ipaddress]:443 if you have fixed IP addresses associated with your server).
This will explain the difference in behaviour.