How to setup AWS cloudfront with lightsail for WordPress? - 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.

Related

Use IP instead of domain in Cpanel

I have access to a CPanel associated with a primary domain name www.test.com and it's IP is 55.666.777.888.
However, we must point the domain to another IP address temporarily and do some set-up on this server at the same time. The issue is I cannot access 55.666.777.888 to set up WordPress after having redirected www.test.com to another IP. The domain must always serve another website in the mean while.
When I visit the Domain page, www.test.com is still listed as primary domain.
Is there anyway that we can disable the domain temporarily and access the site using the IP then revert it later?

how to point multiple domains to the same website?

test.com DNS to cloudflare and I configured the www A record to point to google firebase. all good here.
I want to point any domain to www.test.com and render exactly the same content. what should I do to achieve this? do I need to create my own DNS in cloudflare and give it to domain admins so they can configure the domain? any pointers will help. thanks!
Providers like Firebase Hosting use the Host header name of the incoming request to determine which customer's content to serve. If other people change their DNS to point to www.test.com, the Host header will still be populated based on the domain they provided.
To make a website serve the same content regardless of domain, you need to either:
Host the content on a dedicated IP address such that the Host header doesn't matter (this is not possible with Firebase Hosting) or
Have all connecting domains proxy to www.test.com as opposed to directly setting DNS and include a Host header of www.test.com when they forward traffic.
In general services where you need to manually configure a custom domain (e.g. Firebase Hosting, Heroku, etc) are not going to support arbitrary other domains pointing to them without an additional layer in between.

whats the difference between custom DNS and FQDN

what is the difference between custom DNS and FQDN, i got this question in my mind when i was using certificate generation for our servers. what is the difference it makes if we use FQDN or custom DNS for generating CSR.
Let's say that your server has the hostname 'anne'.
And lets say that you bought a domain called 'hathaway.com'.
Then yout FQDN is 'anne.hathaway.com'.
The FQDN is the combination of the hostname of the server + the domain.
If you generate a cert for your FQDN it will not reach all the subdomains of your domain.

letsencrypt and DNS A record for subdomains

I have a website behind a firewall lets call it
www.mysite.mycompany.com
I want to enable SSL on the server serving this website.
I am reading this article
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-centos-7
And that article mentions
A DNS A Record that points your domain to the public IP address of your server...
I don't have control over the corporate DNS but since my site is a subdomain of mycompany.com do i still
need to make that DNS A record ?

AWS Route53 routing wordpress subdirectories to different EC2 instances

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

Resources