Notes on Future Web Server To-Dos, Research, and Considerations

English

June 30: Approved for AdSense, on the morning of the 7th day since application. Could the short review period be due to the low number of articles? Maybe making a conscious effort to update articles daily during the review helped. They might even be looking at the growth rate of the site.


Going forward, I'll use this page to jot down my unorganized thoughts, research, and ideas regarding upcoming to-dos, and publish it right from this raw stage. Each item will eventually get its own dedicated article. I'll also update this page as things evolve. At this stage, nothing is finalized at all!


■ To-Dos

■ SSL Implementation

According to Google's announcements, SSL is practically mandatory nowadays. Even without it yet, I still got approved for AdSense.
Should I use the free Let's Encrypt? It looks easy enough, but can't I do it using CloudFront if I'm using that already? Wait, does SSL on AWS require a load balancer? Needs further investigation.

Other tasks involved in SSL setup:
・HTTP to HTTPS redirection
・AdSense registration didn't specify HTTP or HTTPS, so it looks like no action is needed there.

■ Migrating the Old Site

There are two types of status codes: 301 and 302.

■ 301: Generally speaking, a 301 redirect is the standard for passing on SEO value. However, FC2 doesn't allow redirects from FC2 to other providers' servers. It is allowed for paid FC2 plans though, so should I upgrade temporarily to route through there? Or should I just switch to the paid FC2 plan for 300 yen? Since I also have doubts about the cost-effectiveness of AWS, that's definitely an option.
■ 302: Strictly speaking, this is for temporary moves so it shouldn't be the right choice, but Google apparently changed how they handle it at some point, and 302 redirects now pass SEO value as well. Apparently, you can do this even with a free FC2 account.
→ This works.
If I establish a naming convention for the migration, I might be able to specify redirect destinations using a single common file, but that sounds complicated again. I don't have that many articles anyway—might as well review them one by one and edit out any phrasing not suitable for the public eye?

■ Migrating Static HP Content

I have a massive archive of old car maintenance articles. This is a completely different genre from what I want to focus on now—the classic end-state of having too many hobbies. I want to give this a different vibe. I might even use a separate URL like carlife.the-world-star.com to make it look like it's written by someone else. Separating unrelated content is supposed to be good for brand strengthening. That said, Google's search engine apparently doesn't care either way. Bold move.

From an AdSense perspective, the URL is https://the-world-star.com/carlife/, but when clicked or searched, it always redirects to carlife.the-world-star.com. Is that okay? This is a debated topic under the keywords "subdomain" vs. "subdirectory."
Also, it seems you register xxx.maindomain as a subdomain in AdSense. Apparently, you can use it without a review. Since the main domain "the-world-star.com" is already approved, the subdomain "carlife.the-world-star.com" is considered to belong to the same owner, eliminating the need for a review. Is that why xxx.fc2.com URLs aren't allowed?
If that's the case... it means even a separate physical server will work... well, physical location probably doesn't matter at all anyway.
If I use a separate WordPress installation, could I establish a more dedicated, distinct theme? Can I do that even without a separate install? Apparently, there's a feature to manage both under a single WordPress installation. "Install WordPress Multisite"?

By the way, do people even use "www" anymore these days? Since you're accessing via https:, isn't it inherently web traffic?
Should I separate the web presence from the blog? www.the-world-star.com vs. blog.the-world-star.com
The current the-world-star.com is a blog.

■ Blog Subdomain

I want to separate content with different vibes.
The "Server" category within my current blog is just noise to people interested in camping and fishing, so I want to hide it and make it separate.
https://buildserver.the-world-star.com/
Or should I make it a static page that doesn't look like a blog?
It seems possible to create a subdomain with a different look, or a subdirectory with a different look, using WordPress.

■ Migration Classification

Fishing → Keep on the current blog
Old Car HP → Move to a separate static site / subdomain
  Can static pages just live on S3? Entirely on S3: carlife.the-world-star.com → Won't ads fail to display? Some people seem to get them to work though... Needs investigation.
Server-related → Move to a separate static site / subdomain, or keep as a blog in a separate multisite folder?
Right now I'm writing diary-style as I go, so a blog format is probably fine.

■ Lean Site Architecture Using S3

*This is the background on how I naturally concluded that AWS S3 + CloudFront is the way to go.*

Can I host photos, and ideally articles too, directly on S3 for existing sites?
Mount S3 and output via WordPress?
Mounting S3 caused high access latency before, but maybe I only need to mount it while working?
Mount to /var/www/html/carlife?
Was it /var/www/html/contents/uploads/?
Either way, since it's static, won't ads fail to show? → Found articles by people doing this, but it was before review so it's unclear. There aren't many sites thoroughly explaining this, so I should experiment and write an article about it myself. Since it's a subdomain, I should be able to set it up quickly.

■ Over-Engineered Plan

It seems possible to rearchitect things so that EC2 dynamically fetches both photos and articles from an S3-based site and renders them.

Dynamic site →
  Upper section uses a common structural template
   Content fetches and renders text documents from S3. → Not via internal mounting, but over HTTP
   Image links point to https://s3.xxx
  Leave spaces before and after for ads.
What if someone accesses an S3 article directly? That might be treated as the main SEO target. Should I place an .htaccess or canonical tag on S3?

Maybe S3 is painfully slow without CloudFront. Can't I just rely on respective caching servers?

★ Shocking revelation discovered here...
I thought CloudFront was expensive, but it's actually cheap. Base fee: 15 yen/month, and even with 10,000 requests, it's just 17 yen.
As long as images are hosted there, text takes up virtually zero storage.
If I host statically on S3, can I just dump the old site as-is? Is WordPress better for aesthetics?
 → Nah, considering the future potential of an active blog... let's migrate!

■ Conclusion: Serve Images via S3 + CloudFront

I won't have to worry about server storage capacity consumed by image files when uploading articles anymore.
I must have miscalculated or misread pricing before, which is why I abandoned it, but checking again while reviewing other things, I found out it's actually cheap (= base fee of 15 yen/month). This increases the value of using AWS.
Text takes up negligible space, so I can practically use infinite storage for text without worrying about EC2 limits.

■ How to Migrate Smoothly?

Relocate image files to S3. Image files sit right in the EC2 server at /var/www/html/wp-contents/upload/ with their original filenames. Since there are variations in filenames by size, are these automatically resized and generated? I'll probably need all of them. Original filenames including Japanese characters are used, so this might be a good time to rename them to ASCII/alphabetic characters.
Is filename metadata stored in the DB too? Can I get away with a simple copy? Need to update document file links. → Where are they located? Probably stored inside the database.

First, install the "offload media" plugin to handle images on S3, which should let future articles use S3 images seamlessly. Worst case, I can leave past items as they are and migrate them gradually.

■ S3 + CloudFront Migration Strategy

★ This site explains everything.
Migrating images to S3
https://qiita.com/kenji__n/items/b7b5f7e9d39b96c9a869

0. Install the offload media plugin first, set up the S3 side, create folders, and prepare the environment.
 New posts published after this step should be able to use S3.
Since the site explained above leaves the S3 server URL as the default Amazon endpoint, to avoid that, I'll leverage Route53 (which I learned about on Udemy) so content is served from my custom domain, "static.the-world-star.com".
At this point, I should also integrate CloudFront, build the server architecture, and run tests.
 static.the-world-star.com/wp-content/uploads/2022/05
1. Copy image files to S3. Upload them either via the S3 web API to the location prepared by the offload media plugin, or copy them via SSH.
Option 1: Using the standard WordPress API might be fine.
 Option 2: Archive the uploads directory, bring it over, extract it to S3, and upload via the S3 web API.
 Option 3: `aws s3 sync uploads/ s3://bucket-name/wp-content/uploads/` — done in one shot. I'll go with this. Don't forget to clean up locally afterwards.
2. Update image links in published posts. Use the plugin "Search Regex" to batch-convert strings across all articles.
 Only update image links from `the-world-star.com/wp-content/uploads` to `static.the-world-star.com/wp-content/uploads`.
Should I practice regex conversions in Emacs or somewhere first? I need to test it.

Other reference articles:
★https://qiita.com/kenji__n/items/2c917ee020d831ab5f98
Using CloudFront
Using S3 alone might cause billing to skyrocket as traffic increases, so I'll add CloudFront.

★ Apparently, CloudFront lets you route requests for `*/wp-content/uploads` to S3 without changing the content path.
https://qiita.com/fumikoi/items/fe170507c13e6b768e4b
https://dev.classmethod.jp/articles/aws-beanstalk-wordpress-2/
 *It turns out offloadmedia-lite is necessary after all, for uploading items to S3 upon posting.*
This is an official WordPress plugin by Amazon. The official help docs state that the site needs to be running HTTPS.
Amazon Web Services
Amazon S3 and CloudFront

Sounds a bit tricky, but...
1. Configure it following the Udemy instructor's setup... so content appears to be served from static.the-world-star.com
2. Instead of replacing URLs to image files individually, apply the above configuration.
 I feel like this can be achieved by routing traffic to static.the-world-star.com/contents/uploads/.

→ Actually, if I do that, it would probably point all of the-world-star.com traffic to CloudFront, breaking non-web services like my Minecraft server or SSH, so that's likely a bad idea.

From here on, I plan to write a separate article documenting the implementation of the steps outlined in this section.

Leave a Reply