How Do I Configure Configure the Remote Web Server to Use Hsts?


Heather Bennett

How Do I Configure the Remote Web Server to Use HSTS?

When it comes to web security, one of the important aspects to consider is enabling HTTP Strict Transport Security (HSTS) on your web server. HSTS helps protect your website and users by forcing all communication with your server to be encrypted over HTTPS. In this tutorial, we will guide you through the process of configuring a remote web server to use HSTS.

Step 1: Accessing the Server

To configure the remote web server, you need to have SSH access or a control panel provided by your hosting provider. Use your preferred method to access the server.

Step 2: Editing the Configuration File

Once you are connected to the remote server, locate the configuration file for your web server software. This file is typically named “httpd.conf” for Apache or “nginx.conf” for Nginx.

If you are using Apache:

  • Open the terminal or SSH client and navigate to the Apache configuration directory.
  • Use a text editor like nano or vi to open the “httpd.conf” file.

If you are using Nginx:

  • Navigate to the Nginx configuration directory using the terminal or SSH client.
  • Edit the “nginx.conf” file using a text editor of your choice.


If you are unsure about the location of these configuration files, consult your hosting provider’s documentation or support team for assistance.

Step 3: Enabling HSTS

In order to enable HSTS, you need to add an HTTP header directive in the configuration file. This directive instructs the browser to communicate with your server only over HTTPS for a specified amount of time.

Find the section in the configuration file where you can add custom directives. This section is usually indicated by comments or within a specific block of code.

Add the following line within the custom directives section:

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

This line sets the HSTS header, specifying a maximum age of 31536000 seconds (1 year), including all subdomains, and preloading HSTS in browsers that support it.

Step 4: Saving and Restarting

After adding the HSTS directive, save the changes to the configuration file and exit the text editor.

If you are using Apache:

  • Run the command sudo service apache2 restart to restart Apache.

If you are using Nginx:

  • Execute sudo service nginx reload or sudo systemctl reload nginx to reload Nginx and apply the changes.


If you encounter any errors or issues after restarting your web server, double-check your changes in the configuration file for any syntax errors or conflicting directives.

Step 5: Verifying HSTS Configuration

To ensure that HSTS is properly configured on your remote web server, you can use an online tool like This tool checks if your website’s domain is included in the HSTS preload list used by most major browsers.


In this tutorial, we have walked you through the process of configuring a remote web server to use HSTS. By enabling HSTS, you are enhancing the security of your website and protecting your users’ data. Remember to always follow best practices for web security and stay up to date with the latest recommendations.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy