User Tools

Site Tools


information-technology:2019-web-hosting

Researching Web Hosting Options

I wrote this as I went along, researching web hosting technology that was new to me. So it's a story of my discovery process as well as info that may be helpful to you.

I have chosen shared hosting, as it is economical and gives me enough control to make the sites I want, without having to maintain a server on my own. You can have a managed VPS, or managed VPS Cloud, but that costs more.

I don't know how trustworthy these sites are, but I checked them out in searching for web hosting:
http://hostadvice.com
http://hostingfacts.com
http://hosting.review
http://www.reviewhell.com
http://www.hrank.com

If you want a very small company that's been in business since 2002, there is a delightfully small web host called Condorhosting. They have a total of 2 servers in California. Hosting starts at $3 per month.

My requirements are:

  • a linux server with cpanel
  • live chat support 24/7 with low wait time
  • multiple domain plan (such as with “addon” domains)
  • a company with a bit of charm

I considered offshore hosting. Offshore hosting can be beneficial when you don't want local authorities to have power over your website. One good choice for offshore hosting is Iceland, since it is a country that values freedom more so than the U.S1. Icelandic hosting services include 1984 (the most used host in Iceland, named after the dystopian novel), OrangeWebsite, and Flokinet.

However, I realized that offshore also means more latency. The website will be slower for those physically located further away from it. You can see the distances a request has to travel on a map of the undersea fiber optics throughout the world. From NYC, hosting at www.host.md (md for Moldova) had ping response times averaging 150ms, whereas a U.S. based host I've been using had response times of 40ms. Google.com responds in 15ms, since they want to be as close to you as possible, and have a net of servers nearby everywhere.

The latency problem can be solved by having servers everywhere like Google. This is where I am just starting to read about cloud hosting.

I am familiar with DNS. When you type in a web address in your web browser, a DNS translates that into an IP address. The IP address is what the web hardware uses to route your request to the website's server. DNS resolves one web address to one IP address, except, that using a certain technology called Anycast, one IP address can exist in more than one location. But is this the “cloud hosting” that a random web hosting provider is offering? Maybe not all web hosting providers are created equally, or maybe that's not what they mean by “cloud hosting”. I *am* more sure that services like Cloudflare's offer this Anycast DNS.

With Anycast, you can also get IAAS (Infrastructure As A Service). In other words, your server is completely virtual. It doesn't exist in one place. When you ftp to upload files to it, you would be uploading the files to whatever is the closest server to your location. If you are working on your laptop while traveling, that may be a different server depending on where you are. Although that's more fancy than the truth. What's most important is a speedy website to your audience.

One such web host is Hostinger, since they offer CloudFlare Integration in their cloud hosting package. Their VPS hosting also comes with what looks like the same cloud features, and costs less at only $3.95/mth. So both services are cloud host based, but the difference is that the cloud hosting is managed, and VPS hosting is not. If you don't manage the server, you don't have root access, but neither do you have to do the work of managing it. I had to chat with a representative to find out, as the site doesn't make the differences clear.

Another such web host provider is Dreamhost. They also have an unmanaged cloud VPS like Hostinger, which they call DreamCompute. They charge $4.50 a month for an entry-level-virtual-server, plus download bandwidth, at a price to be determined in the future (right now it's free). They also have an option for a managed VPS server, which cost 13.75/mth. Same as with Hostinger, it seems like having to manage a VPS is expensive. You save by managing it yourself? Is that what's going on here? Or is it expensive to manage people like me that don't know what they're doing?

Something tells me I may be a little off describing the services by Hostinger and Dreamhost, but I'm ok with that. I think I got the gist of it for my concerns.

Hostinger pointed me in the right direction, bless their hearts. It looks like, just using CloudFlare is enough. Hostinger's cloud hosting package is more expensive in part because you get more-and-better-hardware and managed VPS on their end. That's nice, but I'll make due with shared hosting, like I make due with a 2006 macbook pro laptop running windows.

CloudFlare has a free single-website account signup. I think CloudFlare gets me an array of features, including the “cloud” thing similar to CDN (Content Delivery Network). Quick search for CloudFlare competitors, shows that CloudFlare is the only one with a free account.1 Also, it is popular on alternativeto.net website (with nothing else having substantial “likes”). Update: mention of other free services like Incapsula, jsDelivr, BootstrapCDN, and Coral Content Distribution Network, here and here.

So it seems that I could have chosen an offshore host, and used CloudFlare for the low latency. However, I chose Hostinger, and so far I am pleased. They are quick to answer questions via chat. Also, kudos that they are an employee owned company!1

A shared hosting plan is still enough for me. I don't need the “cloud hosting” advertised all over the place, nor do I need the overhead of having to manage a VPS. For now, there is CloudFlare. However, as in all things tech, nothing stays the same. Wait, CloudFlare has been around since 2009! Me dinosaur.

Update: Cloudflare may have its benefits, but it is not without issues.
https://www.reviewhell.com/blog/cloudflare-makes-websites-slower
http://pagepipe.com/cloudflare-doesnt-guarantee-consistent-load-times
http://www.webhostingtalk.com/showthread.php?t=1666238
https://www.quora.com/What-are-the-disadvantages-of-using-CloudFlare
https://internetdevels.com/blog/pros-and-cons-of-cdn


Website Uptime Monitoring

Based on Tanya's Recommendation, along with the likes on alternativeto.net, I'm using FreshPing. I used to use Pingdom. I like the UI on FreshPing a lot better. On the site that I'm using Cloudflare, I will be able to track if it is Cloudflare or my site that is having issues.


File Management

Your hosting package comes with cpanel, which has a file manager built in. This is the simplest, and has the benefit of working with files directly on the server, so you don't have to waste bandwidth downloading them.

Another way, is to use an FTP client such as FileZilla. This is the traditional way. Each access method has its advantages.

With the FileZilla user interface, the local files on the left column, and remote files on the right. If you right-click on a remote file, and choose “edit”, the file will download to your system's temp folder and launch in a native editor. When you edit and save this file, FileZilla prompts asking if you want to upload the change. However, there is the limitation that you can't use native tools for batch operations on files, such as:

  • searching and replacing text
  • file comparison with a local backup, to show modified files on the server

Another way, is to mount the hosting server resource as a local drive. For this, there are programs like WebDrive, NetDrive, and Mountain Duck. Compare this with sync applications such as Google Drive, Mega, or Dropbox, which require a local copy of the files on your hard drive. Either of these methods has the advantage of being able to use native tools when working with files on the server, without having the manual steps of downloading them first, uploading them last.

The protocols used to work with online files as if they were local, are WebDav and SFTP (which is not related to FTP or FTPS). I believe some companies such as Google and Amazon have proprietary protocols for their file hosting, although they may also allow standard WebDav or SFTP connections. (verify) I think SFTP may be superior to WebDav, to use native tools, based on this thread. More info on mounting internet drives in the file sync and backup article.


Email Server

Sometime between 2006 and 2009, I tried to depart from Gmail or other web-based providers, by having email on my web hosting server. It didn't work out well, because a little too often my messages were getting routed to people's spam folder. Maybe because I was on a shared web host, and my server was blacklisted? That didn't seem to be the case, and yet still my messages were sometimes in people's spam folder. Maybe if I paid for a dedicated IP, I wouldn't be blacklisted? I gave up and started using Gsuite (formerly known as Google Apps, just to confuse the heck out of you). I hoped to return to using my own server for email, but the forces that be made it hard for me to do so.

Back to the present. I used a website to test the “spaminess” of emails from my web servers:
https://www.mail-tester.com
https://mxtoolbox.com
In the results, they recommended using DKIM. So I enabled DKIM in Hostinger's cpanel → emails → “mail service control”. Normally, that would be it, since Hostinger would be the acting DNS server. However, I'm using Cloudflare for DNS. So I needed to add the DKIM records to Cloudflare.

In Hostinger's cpanel → advanced → “dns zone editor”, I copied the “host” and “txt” values for DKIM, and pasted them into Cloudflare's DNS records. The records will look like this:

host [ very-jumbled-alphanumeric-string._domainkey ]
txt [ v=DKIM1; k=rsa; p=the-longest-mofo-jumble-of-characters-ever-taking-up-several-lines ]

So on the mail-tester site, I have a score of 10 now, despite not having a DMARC record. Mxtoolbox lists some other issues. I may look into DMARC someday maybe.

This person doesn't recommend mixing email with web hosting. For example, she cites down-time, and difficulty of setup. However, neither of these bother me much.
https://carriedils.com/web-hosting-email

Update: I joined a Diaspora pod, and emails from that community ended up in my gmail spam folder. Upon closer inspection, I saw that the email had a DKIM signature. Perhaps the DKIM was not set up correctly? Perhaps Google has a self-interest?


Mod Rewrite and Regex

The purpose of Apache Mod Rewrite, is to redirect an incoming URL request to a new URL. You modify the original URL to something new, because perhaps you've moved your site to a different directory on the server, or you've changed to a new naming scheme for your pages. If the new naming scheme can be reliably machine translated from the old naming scheme, then you use the rewrite engine. That way, people following links to your page's old location, will still arrive at the new location.

For using Apache Mod Rewrite, you will need to understand some of Regular Expressions. Understand the dot, the asterisk, the question mark, and the () which creates a variable you can call later.

The best way to learn is to try out some expressions at https://regexr.com. They have the entry box pre-filled, so don't let that confuse you: delete it and type your own.

You can also try out your try out your “rewriting” with the htaccess tester at https://htaccess.madewithlove.be

You can also use the cpanel gui instead of manually editing the htaccess file. Basically they have a template for typical rewrites. Accessing your site's cpanel depends on your hosting provider, but can usually be found at your-domain.com/cpanel, or cpanel.your-domain.com (substitute com with your tld). In cpanel look for the redirect option.

The following coding sections are beta. They function but have not been fully tested.

Redirecting To and From a Subfolder

I used to have both Elgg and Dokuwiki installed on this site, and the root page gave you a choice of entering into either application. I ended up using only Dokuwiki. Due to wanting to skip over the root page of the site, and redirect to /dokuwiki, I added the following after “RewriteEngine On” and before the other lines above.

RewriteCond %{HTTP_HOST} ^mekineer\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mekineer\.com$
RewriteRule ^/?$ "https\:\/\/mekineer\.com\/dokuwiki\/doku\.php\?do\=index" [R=301,L]

Eventually, I removed Elgg completely, and decided to move Dokuwiki to the root of the site. Since Dokuwiki is portable, this was easy to do, only requiring I move the files. So that any URL pointing to the old location would redirect to the new root location, I removed the previous and replaced it with:

RewriteBase /
RewriteRule ^dokuwiki/(.*)$ /$1 [R=301,NC,L]




Enabling SSL

CloudFlare SSL

First step is to get CloudFlare for your site. Then logged into CloudFlare, click on Crypto, find the SSL option and get the “Certificate” and “Private Key”. Paste these into Hostinger's Cpanel SSL option (CABundle not required). In CloudFlare, enable “Always use https”. Hostinger also has a https switch in their cpanel. I don't know the implications of both being enabled; I think one is sufficient. No apache htaccess editing required.

Shared Hosting Server Provides SSL

If you are on a shared server that already supplies free shared SSL, you can do the following to redirect from http to https. Edit the root .htaccess file for your site, as follows:

The key to redirecting traffic on global basis is to add the following to the top of .htaccess

RewriteEngine On
RewriteCond %{https} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]




SEO Search Engine Optimization

Importance of the URL

A website's URL is important for SEO. For example: https://mekineer.com/information-technology/2019-web-hosting VS\\ http://www.mekineer.com/dokuwiki/doku.php?id=information_technology:2019_web_hosting

In the past this site:

  • didn't use https (SSL)
  • had dokuwiki in a subfolder instead of root
  • used underscores as a word separator (including my own naming of pages and media)
  • used ugly URLs

I followed the steps to use Nice Url's, as described in the dokuwiki documentation, but incoming requests from old links still showed the ugly. This is the normal behavior for Dokuwiki, but I wasn't satisfied. I used htaccess regex to “301” tell user's web browsers and search engines that there is only the one new page, and to stop asking for the old URLs.

Google, the all powerful, say “underscore bad”, unless you are Wikipedia 1. So I renamed all my pages and media with hyphens, and used the plugin “orphans wanted” to clean up internal links. However, existing links created in the past, coming from outside my website, would not find the page's new location. So I used regex to reform the request and provide a 301. The user's web browser then requests the Corrected Nice URL, and the dokuwiki-supplied-regex does it's thing for the internal request.

Here's the current htaccess file dealing with the redirect, before going into the rewriting supplied by the dokuwiki documentation:

RewriteEngine on

RewriteBase /

RewriteRule ^dokuwiki/(.*)$ $1 [R=301,L]

RewriteCond %{QUERY_STRING} ^(id=)([^\:]*)\:(.*)$
RewriteRule $(.*)$ %2/%3 [E=underscores:Yes,QSD]

RewriteCond %{ENV:underscores} ^$
RewriteRule ".?" "-" [S=6]

RewriteRule ^(.*)_(.*)_(.*)_(.*)_(.*)_(.*)_(.*)$  $1-$2-$3-$4-$5-$6-$7 [QSD]
RewriteRule ^(.*)_(.*)_(.*)_(.*)_(.*)_(.*)$  $1-$2-$3-$4-$5-$6 [QSD]
RewriteRule ^(.*)_(.*)_(.*)_(.*)_(.*)$  $1-$2-$3-$4-$5 [QSD]
RewriteRule ^(.*)_(.*)_(.*)_(.*)$  $1-$2-$3-$4 [QSD]
RewriteRule ^(.*)_(.*)_(.*)$  $1-$2-$3 [QSD]
RewriteRule ^(.*)_(.*)$  $1-$2 [QSD]

RewriteCond %{HTTP_HOST} ^mekineer\.nerdondemand\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC,OR]
RewriteCond %{https} off [OR]
RewriteCond %{ENV:underscores} ^Yes$
RewriteRule (.*) https://mekineer\.com/$1 [R=301,L]

The above underscore removal was necessary to be multi-line, because of a deficit of the apache rewrite engine.

Subdomain versus Subdirectory

information-technology/2019-web-hosting.txt · Last modified: 2019/06/22 16:09 by marcos