AWS Route53 routing wordpress subdirectories to different EC2 instances - wordpress

I have domain setup like http://www.example.com/in which is a wordpress multisite setup and hosted on a AWS EC2 instance.
I have to make another similar setup with url http://www.example.com/uk but on another EC2 instance.
The domain www.example.com is routed to only one IP of first instance.
Can anyone advise on how I should setup this routing to make this scenario on Amazon Route 53?

Assuming you are serving your site using apache you can add a .htaccess rule on the instance hosting www.example.com to redirect www.example.com/uk traffic to another ip address.
This will mean you rely on www.example.com to redirect traffic for www.example.com/uk. In the event the instance running www.example.com were to become unavailable, www.example.com/uk would become inaccessible.
Alternatively, you can setup a subdomain in Route53 with the following entry
uk.example.com 1.2.3.4
This will mean that www.example.com/uk will need to be accessed using uk.example.com not www.example.com/uk

Related

How to configure nginx to access website using www

I have setup a raspberry pi web server. I'm using nginx and google domains. I have a conf file for that domain in sites-available I configured the server_name to my domain name www.domain.com .domain.com;
The problem is that I can only access the website using .domain.com. When I try using www.domain.com I get redirect to ISP page (unable to find..).
Login to your domain provider's dashboard
If you haven't already added an A record to your DNS settings select Manage DNS and add an A record pointing to your IP address of the host.
You'll essentially need to add a CNAME record to your domain's DNS settings. The 'Name' field should be www
Depending on your provider you may have to wait till about 2- 48hrs to allow it to propagate.

How to setup AWS cloudfront with lightsail for WordPress?

How to setup AWS cloudfront with lightsail for WordPress? (on a subdomain)
I'm using Route 53 for all DNS management. I'm using a static IP from
lightsail, 3.122.2.187
Route 53 has an A record for service.openinfo.nl using an ALIAS to the cloudfront domain name.
Route 53 has an A record for wordpress.openinfo.nl pointing to the
lightsail static IP 3.122.2.187
Cloudfront has an origin domain name of wordpress.openinfo.nl
Cloudfront Origin Protocol Policy is HTTP Only.
Cloudfront Alternate Domain Names is service.openinfo.nl
Cloudfront SSL Certificate is the one issued by Route53 for *.openinfo.nl
Cloudfront Viewer Protocol Policy is Redirect HTTP to HTTPS.
This solution does not work:
The cloudfront distribution service.openinfo.nl does resolve the lightsail server but over http, it does not use the certificate I attached... Should I use redirect http to https?
Also, if I click 'login' it redirects to wordpress.openinfo.nl/wp-login.php i.e. the DNS that I assigned for the purpose of orgin domain name to cloudfront. The WordPress "WP_SITEURL" and "WP_HOME" settings somehow automatically reflect the DNS wordpress.openinfo.nl.
And also, the DNS name wordpress.openinfo.nl resolves the lightsail server (which I don't want because I want all trafic to the wordpress server to go via service.openinfo.nl). How to avoid this?
Background and what I tried:
My lightsail (WordPress) server does not show up in the "Origin Domain Name" dropdown list when creating a new distribution. So what should I do? The only AWS description on this topic that I can find is not clear on that to me.
Using the servers fixed IP address as "Origin Domain Name" in cloudfront is not allowed. So I created a DNS record in Route 53 (wordpress.openinfo.nl) to point to the static IP of my lightsail server. And I added this DNS record as "Origin Domain Name" in cloudfront (also including a https certificate *.openinfo.nl). And I selected the cloudfront distribution as A record, type alias, in Route 53. The cloudfront Alternate Domain Names (CNAMEs) is service.openinfo.nl .
So I also tried creating the service.openinfo.nl as A record (DNS) in Route 53 pointing to the static IP of the WordPress lightsail server. But then I cannot create the same service.openinfo.nl as alias A record...
So I am stuck... Please advice? Many thanks in advance! Wouter
PS: openinfo.nl points to a cloudfront distribution with a certificate which points to a static site in a S3 buckets and works fine.
https://aws.amazon.com/blogs/startups/how-to-accelerate-your-wordpress-site-with-amazon-cloudfront/
https://forums.aws.amazon.com/thread.jspa?threadID=264002
First of all, you need to point your domain to CloudFront. You will want to set up a CNAME record in your DNS zone, pointing to the xyz.cloudfront.net address you get when creating the CloudFront distribution. The name of that record should be "www.example.com" if that's the domain you want to enable CloudFront on. Making example.com (without www) work as well could be a bit more tricky as you can't use a CNAME for technical reasons. Route 53 offers a way around this, but the DNS management in Lightsail is a simpler version of that service essentially. But you can always add an A record for example.com, pointing to your server IP address. Then your server can redirect those requests (additional configuration needed).
Secondly, CloudFront needs to contact your server on some address. You could add a second record to your DNS zone. This time you call it "origin.example.com" (or anything really), make it an A record, and point it to the server IP address.

How do I point my domain to my website that's hosted on an AWS EC2?

The registrar for my domain is godaddy, I go to their DNS records section and I changed the A name to the elastic IP associated with my instance. Now when I type my domain in the browser, my website appears! However, it forwards it to the IP of my server.
Things I've tried (whether logical or not):
I'm using wordpress multsite so I changed the DOMAIN_CURRENT_SITE in wp-config.php to my new domain. No luck. Reverted.
I changed the 'site_url' and 'home' in my database to point to my domain. No luck. Tried one at a time etc. Reverted.
Changed ServerName to my new domain in httpd.conf (apache).
sudo hostname www.... (don't know what that does)
So I'd like to simply have my website open without it showing the IP in the address bar. Can someone help?
Thanks
EDIT:
Here's the DNS page of godaddy, I've blanked out the ip in the A records, but it's just the ip of my server.
First you need to set Custom NS in godaddy with AWS dedicated IPs then set them as DNS. If you are using Linux instance with cPanel then just add the domain in cpanel's addon-domain.
If you are using Windows instance then you should configure IIS.

Can't find my wordpress site when using www

If I do example.com my site is there, but when adding www. or http://www. I get the error message: server DNS address could not be found.
I'm pointing my domain to EC2 on Amazon Web Services.
What am I missing?
You have to add a CNAME record for the www subdomain pointing at your EC2 Ip and also I recommend you to make a permanent redirect on your virtual host config file of your web server (apache for example) to redirect http://myexample.com to http://www.myexample.com. If you do not prefer making a permanent redirect you need to include www.myexample.com in your virtual host file as an alias.
Do you have CNAME DNS records set for www on GoDaddy? Try set www to # under DNS Settings CNAME. Read support article here

Connecting Amazon Web Services with Elastic IP

Right now I have a domain ex: foobar.com hosted on Bluehost.
I created an instance on AWS and fortunately, I used (wordpress by bitnami) to migrate my foobar.com to the aws site.
I created an elastic ip and associated it with my instance.
This is where I am stuck. I've read tons of tutorials telling me to go into my Bluehost and add a DNS record which I haved.
My first attempt was to do a URL redirect on foobar.com, which worked but only for the homepage because when I would navigate to another page, it would display the elastic ip (ex: 53.13.153.12/about).
I am unsure how to go about this problem.
Setup an A Record, not a URL redirect. You'll need to then configure the vhost on your server to understand that domain (I think you may have already done this step).
Bluehost has some documentation here

Resources