WeWP
ComparePricingFeaturesContact UsLoginTry For Free
  • Knowledge Base
  • How to Fix "Not Secure" or "Not Private" Connection Errors
  • How to Add Cron Jobs
  • Connect to Your Server via SSH on Windows
  • Keeping Servers and Sites Secure
  • Troubleshooting Cloudflare Issues
  • Install WordPress Themes and Plugins with Composer
  • How To Fix Mixed Content Issue For WordPress
  • What Is a DDoS Attack and How to Prevent It?
  • How to Enable WordPress Debug Mode
  • How to Fix the “MySQL server has gone away” Error
  • How to Configure WP Mail SMTP Plugin to Send Emails
  • How To Fix the “HSTS Missing From HTTPS Server” Error
  • How to Check Your Domain's Expiration Date
  • How to Use and Serve WebP Images in WordPress
  • Email security best practices for using SPF, DKIM, and DMARC
  • What is a LEMP (Linux, Nginx, MySql, PHP) Stack?
  • Deploying Web Applications with NGINX HTTP Server
  • How to Configure WP Rocket Plugin for WordPress
  • How to Check SPF and DKIM Records with WeWP
  • Understanding FTP vs SFTP: Which Should You Use for Secure File Transfers?
  • What is a DMARC record and How to Set it Up?
  • How to Set Up Cloudflare’s Free CDN for WordPress
  • How to check your Ubuntu version (Using the command line and GUI)
  • How to Download Backups from WeWP panel
  • How to Change the PHP Version of Your Hosting Plan
  • Troubleshooting Cloudflare Universal SSL
  • How to Fix “Your Domain Is Not Pointing” Error
  • SSH vs SSL: What’s the Difference?
  • WordPress Search and Replace
  • How to Force HTTPS on WordPress Websites
  • How to Fix a Failed Lifetime SSL Installation
  • How to Redirect HTTP to HTTPS
  • How to Monitor System Processes Using htop Command
  • Varnish vs Nginx FastCGI Cache: Which is Best for WordPress?
  • What Is the Database information_schema on phpMyAdmin?
  • How to Disable WP-Cron for Faster Performance
  • How to fix the ERR_SSL_PROTOCOL_ERROR
  • How to fix the NET::ERR_CERT_AUTHORITY_INVALID error
  • How to Add Expires Headers in WordPress
  • How to fix the “There has been a critical error on your website” error
  • How to Fix ERR_QUIC_PROTOCOL_ERROR in Chrome Browser
  • What Is Localhost? And How Does It Apply to WordPress?
  • How to Fix a Mixed Content Warning on Your Website
  • How to Fix the "Connection Timed Out" Error in WordPress
Powered by GitBook
On this page
  • 1. Understanding HSTS
  • 2. Prerequisites
  • 3. Edit the Nginx Configuration File
  • 4. Add the HSTS Header
  • 5. Test the Configuration
  • 6. Reload Nginx
  • 7. Verify the HSTS Header
  • Conclusion

Was this helpful?

How To Fix the “HSTS Missing From HTTPS Server” Error

HTTP Strict Transport Security (HSTS) is a web security policy mechanism that helps protect websites against man-in-the-middle attacks such as protocol downgrade attacks and cookie hijacking. When a server has HSTS enabled, it informs the browser to only interact with it over HTTPS. The “HSTS Missing From HTTP Server” error indicates that this policy is not correctly configured on your server. Here’s how to fix it:

1. Understanding HSTS

HSTS is implemented via an HTTP response header. When a browser receives this header from a server, it will only communicate with the server over HTTPS for a specified period. The header looks like this:

Strict-Transport-Security: max-age=31536000; includeSubDomains

  • max-age: Specifies the time, in seconds, that the browser should remember that the site is only accessible via HTTPS. For example, 31536000 seconds is equivalent to 1 year.

  • includeSubDomains: Optional directive that applies this policy to all subdomains of the site.

2. Prerequisites

Before enabling HSTS, ensure:

  • Your website is fully accessible via HTTPS.

  • All HTTP pages are redirected to their HTTPS counterparts.

  • You have a valid SSL/TLS certificate installed on your server.

3. Edit the Nginx Configuration File

You need to edit your Nginx configuration file to add the HSTS header. This configuration file is typically located in one of the following directories:

/etc/nginx/sites-enabled/your-sitename.conf

4. Add the HSTS Header

4.1 Open the Configuration File:

Open the configuration file for your site using a text editor. For example:

sudo nano /etc/nginx/sites-enabled/your-sitename.conf

4.2 Modify the Server Block:

Locate the server block handling HTTPS traffic. It typically looks like this:

server {

listen 443 ssl;

server_name your-site.com;

ssl_certificate /path/to/your/certificate.crt;

ssl_certificate_key /path/to/your/private.key;

# Add the HSTS header

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

# Other configuration directives…

}

4.3 Add the HSTS Header:

Within the server block, add the add_header directive:

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

Here’s an example of what the server block might look like after adding the HSTS header:

server {

listen 443 ssl;

server_name your-site.com;

ssl_certificate /path/to/your/certificate.crt;

ssl_certificate_key /path/to/your/private.key;

# Add the HSTS header

add_header Strict-Transport-Security "max-age=31536000;

includeSubDomains" always;

location / {

# Your site configuration...

}

}

5. Test the Configuration

Before applying the changes, it’s essential to test your Nginx configuration to ensure there are no syntax errors.

Run the following command:

sudo nginx -t

If the test is successful, you should see output similar to:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

6. Reload Nginx

After verifying the configuration, reload Nginx to apply the changes:

sudo systemctl reload nginx

7. Verify the HSTS Header

Finally, verify that the HSTS header is being sent correctly. You can do this using various online tools or by checking the response headers directly.

Using curl:

Run the following command:

curl -I https://your-site.com

Look for the Strict-Transport-Security header in the response:

HTTP/1.1 200 OK

Server: nginx/1.18.0 (Ubuntu)

Date: Thu, 30 May 2024 12:00:00 GMT

Content-Type: text/html

Content-Length: 612

Last-Modified: Wed, 29 Apr 2020 15:00:00 GMT

Connection: keep-alive

ETag: "5ea9cd00-264"

Strict-Transport-Security: max-age=31536000; includeSubDomains

Conclusion

→ By adding the HSTS header to your Nginx configuration, you enforce strict transport security, ensuring that all communications with your server are conducted over HTTPS. This significantly enhances the security of your website by protecting it from protocol downgrade attacks and cookie hijacking.

PreviousHow to Configure WP Mail SMTP Plugin to Send EmailsNextHow to Check Your Domain's Expiration Date

Last updated 11 months ago

Was this helpful?