Tutorial: Securing WordPress Installation running on NGINX Web Server. Pt.2

Securing your website is crucial to protect your website from cyber attacks and keep your users’ information safe. In this tutorial, we will cover additional steps to secure your website running on Nginx, including disabling directory listing, configuring rate limiting, and implementing HTTP Strict Transport Security (HSTS).

Step 1: Disable Directory Listing

Directory listing allows anyone to view the files and directories on your server. This can be dangerous as it can reveal sensitive information to attackers.

To disable directory listing, add the following line to your Nginx server profile:

autoindex off;

This will prevent Nginx from displaying directory listings when a user navigates to a directory that doesn’t have an index file.

Step 2: Configure Rate Limiting

Rate limiting can help prevent brute force attacks, DDoS attacks, and other malicious activity by limiting the number of requests a user can make in a given time period.

To configure rate limiting, add the following lines to your Nginx server profile:

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_req zone=one burst=5;

This will limit requests to one request per second and allow bursts of up to five requests.

Step 3: Implement HTTP Strict Transport Security (HSTS)

HTTP Strict Transport Security (HSTS) forces browsers to use HTTPS instead of HTTP for all communication with your website. This helps prevent attacks such as man-in-the-middle attacks and session hijacking.

To implement HSTS, add the following lines to your Nginx server profile:

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

This will instruct browsers to use HTTPS for all communication with your website for one year (31536000 seconds) and include all subdomains.

Step 4: Install Security Plugins

In addition to the steps outlined above, you can also install security plugins to protect your website.

Here are some additional security plugins you can consider:

iThemes Security

iThemes Security is a comprehensive security plugin that includes features such as malware scanning, two-factor authentication, and brute force protection. You can install iThemes Security by following the steps in the WordPress dashboard.

All In One WP Security & Firewall

All In One WP Security & Firewall is a security plugin that includes features such as login lockdown, file change detection, and firewall protection. You can install All In One WP Security & Firewall by following the steps in the WordPress dashboard.

WP Fail2Ban

WP Fail2Ban is a plugin that integrates with the Fail2Ban software to block IP addresses that are repeatedly attempting to log in to your website with invalid credentials. You can install WP Fail2Ban by following the steps in the WordPress dashboard.

In Conclusion:

By following the steps outlined in this tutorial, you can take additional measures to secure your website running on Nginx. Disabling directory listing, configuring rate limiting, implementing HTTP Strict Transport Security (HSTS), and installing security plugins can help protect your website from malicious attacks and keep your users’ information safe.

Leave a Reply

Scroll to top