DEV Community

Cover image for [Day 4] Installing and configuring nginx
Wojciech Wernicki
Wojciech Wernicki

Posted on • Updated on

[Day 4] Installing and configuring nginx

Hello guys!

It's time for me to set up a WWW server on my VPS! I will both set up nginx and secure it by adding an SSL certificate.

Installing nginx

This one is pretty straight-forward.

sudo apt update
sudo apt install nginx
Enter fullscreen mode Exit fullscreen mode

Firewall

Next thing is to allow nginx to connect outside the server. I need to update UFW settings. First thing is to check up what nginx rules I should allow connecting through the firewall:

sudo ufw app list
# Output
Available applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH
Enter fullscreen mode Exit fullscreen mode

I will allow Nginx Full:

sudo ufw allow "Nginx Full"
Enter fullscreen mode Exit fullscreen mode

Now I should be able to see default nginx page when I hit the IP address of my machine:

Default page served by nginx on my machine

I will skip here part of configuring a domain for nginx. I followed this Digital Ocean — only step 5.

SSL

I followed instructions from this tutorial on Digital Ocean, all the steps that are written up there. In step 4. I chose that nginx should redirect all requests to secure HTTPS version.


That's all for today's session. In the next one, I want to set up a database. See you tomorrow!

References


Cover image: Photo by NeONBRAND on Unsplash

Top comments (0)