Security in Nginx

Krupa Bhimani
Mar 8, 2022

Hello readers, Today in this web server series I am going to explain how can we secure Nginx.We can secure nginx in various ways.

Step 1: Update for latest version

Step 2: Hide http headers

Edit /etc/nginx/nginx.conf file

Add sever_token off;

Step 3: configure SSL

Configuring SSL will ensure a higher level of protection for your data.

Create directory for SSL certificates

Create self signed certificate using openssl

Create snippets

Create another snippet which will define more configuration about ssl

Add configuration to use ssl in file of sites-available

This 2 server block will redirect http request to https

Check status and restart nginx

In browser type localhost

--

--

Krupa Bhimani

2X AWS Certified, DevOps Engineer, Microsoft Learn Student Ambassadors (Alpha)