Website Hosting
This is my first ever article for this website, so I thought I should write about how I actually set this fucker up (spoiler alert I did not have a good time).
The website is hosted using AWS, and the domain was registered with NameCheap. If I was to do this again, I would probably look at registering the domain through Amazon�s Route 53, just so everything is in the same place and works nicely together.
Create an S3 bucket. Name it whatever (mine is just called canbruh.com). The only important setting here is to uncheck the �Block all public access� checkbox (this is not insecure it will be fixed later).
After uploading your website files, under permissions edit the bucket policy, and paste the following code (I got it somewhere on the AWS website so it�s probably safe):
Remembering to replace YOURBUCKETNAMEHERE with your bucket name. From my limited understanding, this just means that the public can only have read access to the bucket, so that they can access the website and nothing more, which is why this is safe.
To enable static web hosting, at the bottom of the properties page edit the static website hosting and enable it. Specify the index document as index.html.
Boom, you now have a hosted website. Return to the static website hosting section under properties, and click the bucket website endpoint link. You should see your website :). If not, suffer.
We need this bad boy to certify to Amazon that we do actually own the domain and aren�t being sneaky. This also allows us to use HTTPS. Go to AWS�s certificate manager AND BEFORE REQUESTING A CERTIFICATE change your location to us-east-1. You will be able to do this with the dropdown menu in the top right hand corner. If you do not do this, Cloudfront will not accept your SSL certificate.
After changing your location, request a public SSL certificate. In the fully qualified domain name section, add BOTH your naked domain (in my case canbruh.com) AND your www version (www.canbruh.com). Yes you need both, I don�t make the rules.
Personally, I prefer the email validation method rather than the DNS validation because I hate dealing with my DNS, but if you would like to use that instead, follow this guide.
After it has been issued, we can move on to Cloudfront.
Create a new Cloudfront distribution. Click on the origin domain box, and your S3 bucket should appear. Click on it. You should get a warning about how this bucket has static hosting enabled, and to use the website endpoint instead. Heed the warning.
I selected to not enable security protections under the Web Application Firewall section because it�s like $8 USD per month and I don�t have the cheese for that.
Under alternate domain name (CNAME), add both your naked domain and your www domain, and choose your certificate from the dropdown menu. If it�s not there, you probably did not choose the right region before requesting your SSL certificate. For not doing that look here
Specify your default root object as index.html, and create the distribution. Wait for it to deploy (should be a few minutes), and then access the distribution domain name. If you open this link in a browser, your website should pop up and everything is golden.
Now to configure our DNS. Sign into your domain manager of choice, for me it is NameCheap, so all this info will be for NameCheap specifically, but the gist is the same.
Add two CNAME records, one with host @, and one with host www, both with the value of your distribution domain name (it's a CloudFront thing) (ensuring to remove the https:// part first). The host @ specifies the naked domain (canbruh.com), and the host www specifies the www version (www.canbruh.com).
Now, if you wait several hours, it should now work.