So I have a domain whose nameservers are pointed to AWS Route 53. My site is hosted on an EC2 instance and is reachable but only resolves to site.com, even if you input www.site.com. I'm curious how to get the site to resolve to www.site.com. I have under Route53 for my domains hosted zone 2 additional record sets outside of NS and SOA:
A site.com EC2 Elastic IP
CNAME www.site.com EC2 public DNS
I can reach the site using both site.com and www.site.com, but it will always resolve as site.com. Is there a way to make it so that if I enter either, it resolves to www.site.com?
At first, both should be A record set.
A site.com EC2 Elastic IP
A www.site.com EC2 Elastic IP
And need redirect setting in your web server (nginx, apache, ..) as following. (Source: How To Redirect www to Non-www with Nginx on CentOS 7)
Redirect non-www to www
If you want redirect users from a plain, non-www domain to a www
domain, add this server block:
server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
Save and exit. This configures Nginx to redirect requests to "example.com" to
"www.example.com". Note that there should be another server block that
defines your www web server.
Related
Let us use example.com for my situation. I have deployed an Elastic Beanstalk application. Within the application, I have modified the EC2 Application Load Balancers, to automatically redirect HTTP to HTTPS traffic.
In Route 53 this is my current configuration
Name Type Value
example.com. A ALIAS www.example.com.
example.com. NS 4 aws name servers
example.com. SOA Values provided by Amazon
www.example.com. A ALIAS elastic beanstalk url
Under this configuration http://example.com --> https://example.com and http://www.example.com --> https://www.example.com
Instead, how do I have the configuration to be https://example.com --> https://www.example.com or http://example.com --> https://www.example.com ?
I have deployed my application on EC2 - ubuntu 18.04 (Apache server). I registered this EC2 with an Application Load Balancer, I want to redirect non-www traffic to https://www.mydomain.co
When I type www.mydomain.co in browser, it redirects to https://www.mydomain.co which is working fine.
But when I type without www that is only mydomain.co then it shows "This site can’t be reached".
Following are the rules I defined in ALB -
Can anyone help please?
This should be done on the domain level, not on the load balancer.
If you use Route53, then you should create a new ALIAS record mydomain.co which points to the URL of your load balancer. Or a record redirecting mydomain.co to www.mydomain.co.
This way both mydomain.co and www.mydomain.co will be directed to the ALB.
If you don't use Route53, similar operation should be performed on your domain registrar.
I am try the config the same setting,
on Route53, I have 2 (A) records both pointed to the alb server
domain.com -> ALB DNS Name
www.domain.com -> ALB DNS Name
You have 2 listeners on ALB Port 80 and 443
on port 80, use 301 redirects to All traffic to HTTPS (Port 443)
on Port 443, points the destination to your desired webserver
config listener
config https handler
so I can do "domain.com"
but I cannot do "www.domain.com"
additionally, when I add "https" to the beginning I get a "connection not private" message, however I have a public cert from amazon.
any ideas what's up with either problem?
The www part is a subdomain of domain.com. You will need to handle routing when users visit this subdomain. You can either serve the same files as on the root domain, or you can redirect to domain.com.
To access your site via https you need to configure SSL.
You can use CloudFront and Route53 to solve these issues.
Here is a guide on handling routing for subdomains in Route53.
I have bought a domain in aws, and I have a PC in my home which I use as server, how can I redirect/serve the traffic between aws and my server's public IP?
The server is listening to the port 8002 and has ip 192.168.1.x
I exposed the port 8002 in the router to 192.168.1.x:8002
If I go to my server's public ip and port (eg: 203.0.113.x:8002) I can see my website, but when I modify in Route53 the destination (A) set my IP, and I go to mywebsite.com it doesn't load the site, instead it load the apache default page.
In my server I have modified my apache2 configs to set the ServerName as follow:
ServerName www.mywebsite.com
ServerAlias mywebsite.com
I followed the info in https://aws.amazon.com/premiumsupport/knowledge-center/redirect-domain-route-53/ but in the last step when I want to select the created bucket it doesn't appear in the list.
Make sure your internet router at home allows you to connect on this ip from external network ( NAT may be reuqired).
Look like the procedure you sent involves hostname redirection with s3 which i'm not sure it is what you want to do.
Note
Above link you have mentioned is for redirect form one domain to another(like example.com to somedomain.com)
Follow the below steps for your case:-
Create A-record in route53 and add the CANAME if anything there.
E.g:- example.com A-record 123.45.67.89
www.example.com CNAME example.com
Check the TTL(if you have TTL value high wait for some time to reflect all DNS servers)
I am hosting my website on amazon web services. I use a beanstalk application and have an A-record that directs the address www.domain.com to the beanstalk. I also have the same domain but with a .org at the end. I also created an A record that points the domain.org to the same beanstalk application. This works. The problem is that I will buy a ssl certificate for the domain.com and therefore I need the user to be directed to the domain.com when he/she enters domain.org. I tried adding a CNAME record for the domain.org address with the value domain.com. The result is that the user ends up in the correct page but the address in the url bar is domain.org which might cause a problem since the certificate is for domain.com.
DNS cannot do any redirection. That's purely HTTP-level material. You would need to configure your .org vhost to do that, e.g. on apache:
<VirtualHost *:80>
ServerName www.domain.org
RedirectPermanent / http://www.domain.com
</VirtualHost>
Your CNAME is basically pointless. All it does is point a hostname at another hostname, which causes your DNS resolver to fetch the IP of that "another host". It then uses that IP as the IP for the original name. e.g.
domain.org -> CNAME pointer -> domain.com -> a.b.c.d
which then does an HTTP request to the a.b.c.d IP with
Host: domain.org
in the http request header.
You can use Amazon S3 to do this.
Create an S3 bucket called domain.org
Enable Static Web Hosting on the new bucket by choosing "Redirect all requests to another host name"
Set domain.com or www.domain.com as that other domain
If you are using Route53 for your DNS, you can create an Alias record for domain.org to point to your bucket. If you are not using Route53, then create a CNAME to your bucket's public URL.
You can easily do similar things for domain.com -> www.domain.com if you are using Route53.