DevOps Lab: Run Your Own Web Server
By Sudheer S
Once upon a time, Apache was the de-facto web server solution. Later, Nginx became popular. If you are getting started with DevOps and Linux system administration, I would recommend you to start with Nginx.
Start With A Static Website
What is a static website? A website made from HTML and CSS. And maybe some JavaScript, images, videos, fonts, etc. The
key takeaway is that there is no server side application involved. Install the Nginx web server on your Linux VM.
Configure it to serve a static website. You will need a static website as a per-requisite. Create a static website by
assembling some HTML, CSS, JavaScript and images. Optionally, add some fonts and videos. Access the website from your
web browser by typing the IP address of the web server in the address bar. Take it to the next level by pointing
the DNS A record of your domain to the VM. For our purposes, a fake domain or a local unregistered domain is
sufficient. Manipulating /etc/hosts
is also fine. Enjoy viewing the website from the browser.
Host A Dynamic Website
A dynamic website as opposed to a static website, involves an application sitting on the server side. Host a dynamic web application created using any programming language such as PHP, Ruby, Python, Go, Java, etc. Either you can create one yourself and or just download and use an open source web application such as WordPress, Drupal, etc. Learn what is a reverse proxy and how you can leverage it to host dynamic web application. Typically, web applications require a database server such as MySQL, MariaDB or PostgreSQL. Be prepared for a detour to configure the database server.
HTTPS
Learn, what is HTTPS and how you can use certificates to serve a web application over HTTPS. Learn how to use the Let’s Encrypt client to obtain a certificate and install it on your web server. Automate the certificate renewals by writing some shell scripts.
IAC
As with any other DevOps project, use IAC to manage the web servers.
Optional Exercises
- Instead of Nginx, use Apach2 webserver
- Implement Basic Auth.
- Play with caching, compression, response codes, redirects, etc
- Learn to use an open source web application written using different programming languages: PHP, Ruby, Python, Java, Go, JavaScript, etc
Tech Chorus References
Resources
- Video by Traversy Media: HTTP Crash Course & Exploration
- Ubuntu tutorial: Install and configure Nginx
- Certbot