Noah Quanrud

nginx (arch-linux)

Blog

NGINX on Arch Linux

1. What is Nginx and Why I Wanted it

Nginx is a free, open-source software for web serving, reverse proxying, caching, and other things for HTTP servers. I used Nginx because one, you can get it easily on Arch Linux using pacman and two, I wanted to make my website use HTTPS. In order to have my website use HTTPS I needed to obtain an SSL-certificate to have a secure way to send information over the internet. Using certbot for Arch Linux, there is a guide for Nginx. Simply following the guide gave me a SSL-certificate and set an automatic renewal so my site will always be safely secured.

2. Configuring Nginx

When I started configuring Nginx, the first thing I did was set my url locations to have a sligthly different address to differentiate the different projects. For example, noahquanrud.com/about became noahquanrud.com/server_website/about , where the server_website is the project name to help clarify what p roject the page pertains to.My next step was to create an error log and an access log. In the configuration file, I added "error_log /path/to/error/log error-level" to create a error log in the desired path that shows any info at or above the error level. Similarly for the access log I added "access_log /path/to/access/log log_format" where you can specify what is to be shown per access in the log_format. I used "cat /path/to/error.log" or "cat /path/to/acess.log" to view all of the contents of the desired log, or "tail -f" in replace of "cat" to view the most recent 10 lines.

After every change it is important to reload the nginx configuration file to apply the changes. For me I used "nginx -t" to first test the file, then "nginx -s reload" to apply the changes to the configuration file.

3. Bug on Nba Site

When I obtained the SSL certificate, my site started being 'crawled' upon by google robots, basically it follows every link it can find on one page, then follows the links of the pages to find more links and so on. My basketball site only contains data from the 16-17 NBA season, so when the bots followed the link that shows the stats from the last 30 days, it was looking for stats from November of 2018. Since I didn't have any stats from the 18-19 NBA season, it caused an error and would crash the server holding nba site.

nginx-error

[error] message for url that asks for the stats of the last 30 days.

4. Quick Fix and Conclusion

To solve this minor issue, I simply removed the links that were causing the problems and set an assert function so the input year can only be pertaining to my 2016-17 nba season year. After the fix, no problems have arised in the error log and it looks like the Nginx and SSL integration works well. So espite the small setback setting up nginx, I found the overall experience of configuring Nginx, obtaining an SSL-certificate, and using HTTPS very smooth and extremely worthwhile.