Skip to main content
Legia

Cybersecurity

Hardening Company Web Servers: A Checklist for IT Teams

A freshly installed web server is usually tuned to be easy to use, not to be secure. This checklist summarizes the configuration IT teams should review, from TLS and security headers to file permissions, logs, and updates.

SEO and Content Specialist

8 min read Reviewed by Legia Cybersecurity Team

A glowing electronic circuit diagram on a glass panel

Short answer: web server hardening means changing a web server’s default configuration so it serves only what is needed and exposes as little information as possible. The core checklist: TLS 1.2 and 1.3 only, security headers such as HSTS and Content-Security-Policy, server version hidden, unused modules and sample files removed, processes running as a restricted user, logs stored separately, and updates applied on time.

NIST SP 800-123 notes that default software configurations are usually set to emphasize features and ease of use, at the expense of security. Web servers newly installed in the office, in a data center, or in the cloud inherit that trait. The web server hardening checklist below covers the web server configuration side, for nginx, Apache HTTP Server, or IIS. Securing admin access to the server itself (SSH keys, two-step authentication, one account per person) is covered separately in Securing Server Admin Access, so it is not repeated here.

Where should web server hardening start?

Hardening starts from a written reference, not from an administrator’s memory. Two references are commonly used:

  • CIS Benchmarks, configuration recommendations developed through consensus among security experts. CIS publishes benchmarks for NGINX, Apache HTTP Server, and Microsoft IIS, which can serve as a per-version checklist.
  • NIST SP 800-123, Guide to General Server Security (2008). Its main principle: install the minimum services needed, close known vulnerabilities through updates, and remove unneeded applications, services, or scripts right after installation.

Record the initial configuration before changing it, then apply changes gradually on a test server. Web servers serving older applications sometimes depend on settings you are about to turn off.

Illustration: server

Checklist 1: TLS and certificates

TLS encrypts traffic between visitors and the server. The Server-Side TLS guidelines once published by Mozilla, now maintained by the TLSRef community working group, name the Intermediate profile as the recommended configuration for the vast majority of services.

  1. Allow only TLS 1.2 and TLS 1.3. In the Intermediate profile, TLS 1.2 is the minimum version. The nginx documentation shows the default ssl_protocols value is now TLSv1.2 TLSv1.3, but older configurations often still list older versions explicitly. Check the file instead of relying on the default.
  2. Choose the certificate type. The guidelines recommend ECDSA P-256 certificates, or RSA 2048-bit, with a 90-day validity (at most 366 days). Short validity requires automated renewal.
  3. Enable HSTS so browsers always use HTTPS. The max-age value used in the guidelines is 63072000 seconds, or two years.
  4. Generate the configuration with a tool rather than copying from a forum. The Mozilla SSL Configuration Generator now redirects to the TLSRef Configurator, which produces a ready-to-paste configuration for your server software.

Checklist 2: security headers

Security headers are instructions from the server to the browser about what a page may and may not do. The OWASP Secure Headers Project publishes a list of headers with reference values, including:

HeaderOWASP reference valuePurpose
Strict-Transport-Securitymax-age=63072000; includeSubDomainsEnforces HTTPS, including on subdomains
Content-Security-Policydefault-src 'self'; form-action 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requestsRestricts sources of scripts, styles, and frames
X-Content-Type-OptionsnosniffStops the browser from guessing file types
X-Frame-OptionsdenyStops the page from loading inside another site’s frame
Referrer-Policyno-referrerLimits the referring address information sent
Permissions-PolicyFeatures such as camera, microphone, and location turned offCloses access to browser features you do not use

The Content-Security-Policy value above is very strict and will almost certainly need adjusting for your application, for example if it loads analytics scripts or maps from other domains. Test on a test server first. In nginx, also note two behaviors of add_header: without the always parameter the header is only sent with certain response codes, and a block does not inherit add_header from its parent block if it has its own add_header. For X-XSS-Protection, the OWASP HTTP Headers Cheat Sheet warns that this header can actually create vulnerabilities on otherwise safe sites, and recommends CSP instead.

Checklist 3: hide versions, remove what you do not use

Version information makes it easier for attackers to match your server against known vulnerabilities. NIST SP 800-123 recommends that service banners on internet-facing servers not report the server and operating system type and version. NIST also notes that this deters novice attackers but does not stop more skilled ones, so it complements updates rather than replacing them.

  1. Turn off version information. In nginx, server_tokens defaults to on, which shows the nginx version on error pages and in the Server header. Change it to off.
  2. Remove headers that reveal the technology. The list of headers the OWASP Secure Headers Project recommends removing includes Server, X-Powered-By, and X-AspNet-Version.
  3. Delete sample files and bundled documentation, including test scripts and code, as NIST SP 800-123 recommends.
  4. Disable unused modules and services, as well as default accounts created during installation.
  5. Listen only on the ports you need, usually 80 for redirects and 443 for HTTPS.
  6. Make sure directory listings are not shown. In nginx, the autoindex module defaults to off; check that no configuration block turns it on without reason.

Checklist 4: process user, file permissions, and logs

The web server process should run with the fewest privileges possible, so a flaw in the application does not immediately give control of the whole server. NIST SP 800-123 describes the setup:

  1. Create a dedicated user and group for the web server, separate from other users. If the server needs root privileges at startup, make sure it drops to the restricted user after initialization.
  2. Grant read-only access to the files needed to serve, and no access to other files such as server logs.
  3. Allow writing only to folders that truly need it, for example the upload folder.
  4. Restrict temporary files to a dedicated subfolder accessible only to the process that created them.
  5. Separate uploads. Store them on their own partition with a size limit, and do not serve uploaded files until they have been reviewed.
  6. Prevent the server from reading or saving files outside its content folder.

Web server logs are the first record people look for when an attack is suspected. NIST SP 800-123 recommends protecting logs so an attacker who gets in cannot alter them, and says the best approach is to store logs on a separate host, a centralized log server. Logs also need to be backed up and archived, stored in an adequately sized location (ideally a separate partition, so swelling logs do not fill the disk), and reviewed regularly. For admin access logs, see Securing Server Admin Access again.

Checklist 5: updates and periodic checks

A configuration that is secure today can fall behind tomorrow. NIST SP 800-123 says server maintenance includes testing and applying updates in a timely manner and testing security periodically. Web server software makers publish vulnerability information; nginx, for example, has a security advisories page listing vulnerable and fixed versions.

Vulnerability scanning, according to NIST SP 800-123, helps find outdated software versions and missing updates. However, scanners can produce many false findings, so the results need to be read by someone who understands the server. Scheduling is covered in How Often Should a Vulnerability Assessment Be Done.

Web server hardening checklist summary

  1. Initial configuration recorded, changes tested on a test server.
  2. Only TLS 1.2 and 1.3, certificates renewed automatically.
  3. HSTS, CSP, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, and Permissions-Policy in place and tested.
  4. Server version not shown in headers or error pages.
  5. Server, X-Powered-By, and similar headers removed.
  6. Unused sample files, modules, services, and default accounts removed.
  7. Only needed ports open, directory listing off.
  8. Process runs as a dedicated user with only the file permissions it needs.
  9. Logs sent to a separate log server, archived, and reviewed.
  10. A schedule exists for updates and periodic security checks.

How Legia does it

In its Vulnerability Assessment service, Legia checks websites, applications, servers, and cloud. For servers, the check covers the operating system, exposed services, software versions, and configuration. Each scan finding is verified manually, given a CVSS-based severity, then ranked by priority with remediation steps. The whole process usually takes 2 to 4 weeks, the retest after fixes is included, and monthly periodic checks of the same assets are available. As an example, Legia ran a security check on the PT Kebon Agung website for one month after the site went live. If you would rather hand over the fixes, Legia handles them through Server Installation & Management, billed separately. Other services are on the Cyber Security page.

Frequently asked questions

Is it enough to set security headers in the application instead of the web server?

Either works, as long as it is consistent across all pages. Setting them on the web server means the headers are also sent with static files that do not pass through the application. In nginx, add_header only adds headers for certain response codes such as 200 and 301, so add the always parameter if the headers must also appear on error pages. Avoid duplicate headers with different values.

Do TLS 1.0 and 1.1 still need to be enabled for older users?

For most services, no. The Intermediate profile recommended in the TLSRef guidelines sets TLS 1.2 as the minimum version. If a partner system still uses an older version, record it as a written exception and plan its replacement.

Does hiding the server version make the server secure?

Not on its own. NIST SP 800-123 says this step deters novice attackers, but more skilled attackers can still identify the server type. Timely updates remain the main defense.

How often should the web server configuration be reviewed?

Whenever there is a major change, such as a new application, a server migration, or a new web server version, plus a periodic schedule you set. NIST SP 800-123 recommends periodically re-examining the services and information accessible on the server.

Sources

Category Cybersecurity

Keep reading

Related articles

All Articles