In 2014, Google hinted that they are running tests taking into account whether sites use secure, encrypted connections as a signal in our search ranking algorithms. This means it will affect SEO in some way. Today in the age of HTTP2, https is default. Default in the sense that many server software will only allow HTTP2 when https is configured.
The motivation for this post came when I wanted to enable Google Analytics on my site which is under construction. At very least I will be able to get some analytics information.
I will be using Amazon Linux 2 which seems to be made on top of CentOS, but certainly is not CentOS.
While you read this post, take a moment to connect with me on LinkedIn.
In this section, I’ll guide you through the installation process of nginx. If you already have an instance of nginx running, you can skip to the configuration steps. Second thing to install is the certbot.
I would enter following command in the terminal to install nginx as well as certbot:
sudo yum install nginx certbot-nginx
certbot is used for generating TLS certification for our website.
First thing to do after installing nginx is to start and enable the service.
My /etc/nginx/nginx.conf is almost identical to the default instance. The only difference is in the server block where I have removed the instance of default_server.
1
2
3
4
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
to
1
2
3
4
server {
listen 80;
listen [::]:80;
server_name _;
This is for the main config. Now I choose to use separate configs for each of my domain. For that, conf.d subdirectory can be used to place configuration files.
Thing to note here is that I have a Go application running on port 4500, and the domain I own is santosh.pictures. The above application has my gtag being hosted in an index.html, and the text Website under construction.
After configuring this, you can reload the configuration.
sudo systemctl reload nginx
With this, I have just configured reverse proxy for my application. My site right now appear like this.
Installing certbot-nginx also installs certbot. certbot-nginx makes our work by automating the renewal of certificate automatically.
To get started with cerbot, you have nothing much to do. This is a very automated process. You will be asked for some input. Here is how my prompt looked like when configuring the bot.
HTTPS is the new HTTP nowadays already. For next time, I have thought to cover this nginx thing with either Terraform or Docker. Feel free to share it with your network if you found it useful.
If you are looking to enable HTTPS for all of your subdomains, consider reading Wildcard Domain Certificate Using Route53 and Let’s Encrypt. You can use other method of authentication instead of Route53 if you are using other provider than Route53.
If you liked this post, please consider sharing it with your network and please subscribe to the newsletter for new updates.
Author
Santosh Kumar
Santosh is a Pipeline Technical Director at Atomic Arts, building tools and automation for VFX production.