Skip to content
Tech Master Tech Master

OneStopTechnical Forum

  • Books
  • AI
  • Networking
  • Windows
  • Linux
  • Cloud
  • Mac
  • Active Directory
  • Azure
  • Cloud
  • Exchange
  • M365
  • Server 2025
  • Storage
  • Vsphere
  • Website
  • Database
  • Security
  • Knowledge Base
  • VPN
Tech Master
Tech Master

OneStopTechnical Forum

Web Server Security Guide (Nginx, Apache, Caddy, IIS) ๐Ÿš€

blog.payperitem.com, April 2, 2025April 2, 2025

1๏ธโƒฃ General Web Server Security Best Practices

โœ… Keep the Server Updated

  • Regularly update your web server software (nginx, apache, caddy, or iis).
  • Enable automatic security updates for Linux/Windows.

โœ… Run as a Non-Root User

  • Set up a dedicated user for running web services (www-data, nginx, httpd, etc.).
  • Restrict permissions using chown and chmod.

โœ… Use TLS/SSL (HTTPS)

  • Always enable TLS 1.2+ (TLS 1.3 recommended).
  • Get free certificates using Let’s Encrypt (Certbot, ACME.sh).
  • Disable weak ciphers and older TLS versions.

โœ… Disable Unnecessary Modules

  • Remove unused modules to reduce attack surface:
    • Nginx: ngx_http_autoindex_module, ngx_http_ssi_module
    • Apache: mod_status, mod_autoindex, mod_info

โœ… Limit Server Signature Exposure

  • Hide software versions to prevent targeted attacks.
    • Apache: ServerTokens Prod and ServerSignature Off
    • Nginx: server_tokens off;

โœ… Restrict File & Directory Access

  • Block access to .htaccess, .env, phpinfo.php, etc.
  • Use deny all; (Nginx) or Require all denied (Apache).

โœ… Enable Rate Limiting

  • Prevent brute-force attacks with fail2ban or server rate limits.

โœ… Enable Web Application Firewall (WAF)

  • Use ModSecurity (Apache/Nginx) or Cloudflare WAF.

โœ… Enable Logging & Monitoring

  • Store logs in /var/log/nginx/access.log or /var/log/apache2/access.log.
  • Use GoAccess, ELK (Elasticsearch + Logstash + Kibana), or Grafana for analysis.

2๏ธโƒฃ Nginx Hardening Guide ๐Ÿ›ก๏ธ

๐Ÿ”น Basic Security Configuration

Edit /etc/nginx/nginx.conf:

nginxserver_tokens off;
client_max_body_size 10M;
client_body_timeout 10s;
client_header_timeout 10s;
keepalive_timeout 15s;
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;
limit_req_zone $binary_remote_addr zone=req_limit:10m rate=5r/s;

๐Ÿ”น Enable SSL/TLS

Edit /etc/nginx/sites-available/default:

nginxserver {
listen 443 ssl;
server_name example.com;

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
}

๐Ÿ’ก Use Letโ€™s Encrypt to generate a certificate:

bash
sudo certbot --nginx -d example.com

๐Ÿ”น Prevent DoS & Slowloris Attacks

nginxlimit_req_zone $binary_remote_addr zone=one:10m rate=30r/m;
server {
location / {
limit_req zone=one burst=10 nodelay;
}
}

3๏ธโƒฃ Apache Hardening Guide ๐Ÿ›ก๏ธ

๐Ÿ”น Basic Security Configuration

Edit /etc/apache2/apache2.conf:

apacheServerTokens Prod
ServerSignature Off
TraceEnable Off
Timeout 30
FileETag None

๐Ÿ”น Enable SSL/TLS

Edit /etc/apache2/sites-available/default-ssl.conf:

apache<VirtualHost *:443>
ServerName example.com

SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite HIGH:!aNULL:!MD5
</VirtualHost>

๐Ÿ’ก Use Letโ€™s Encrypt to generate a certificate:

bash
sudo certbot --apache -d example.com

๐Ÿ”น Block Bad Bots & User Agents

Create /etc/apache2/conf-available/security.conf:

apache<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(curl|wget|python|scrapy|nmap).*$ [NC,OR]
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) [NC]
RewriteRule .* - [F,L]
</IfModule>

Enable the security module:

bash
sudo a2enmod rewrite
sudo systemctl restart apache2

4๏ธโƒฃ Caddy Hardening Guide ๐Ÿ›ก๏ธ

๐Ÿ”น Basic Security Configuration

Edit Caddyfile:

caddyexample.com {
root * /var/www/html
file_server

tls {
protocols tls1.2 tls1.3
ciphers X25519:CHACHA20-POLY1305:AES256-GCM-SHA384
}

header {
Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
Referrer-Policy "strict-origin"
}

log {
output file /var/log/caddy/access.log
}
}

๐Ÿ”น Enable Automatic SSL

bash

caddy run

Caddy automatically obtains and renews SSL certificates. ๐Ÿš€


5๏ธโƒฃ IIS Hardening Guide ๐Ÿ›ก๏ธ

๐Ÿ”น Disable Unused Features

  • Open IIS Manager โ†’ “Manage Optional Features”
  • Disable WebDAV, FTP, CGI, and Unused Modules

๐Ÿ”น Enable TLS 1.2+

Run the following PowerShell script:

powershell

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server' -Name Enabled -Value 0
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Name Enabled -Value 0
Restart-Service w3svc

๐Ÿ”น Enable Logging

  • Go to IIS Manager โ†’ Logging โ†’ Enable Logs
  • Store logs in D:\IIS_Logs (avoid C:\Windows\System32\).

๐Ÿš€ Summary: Secure Your Web Server

โœ” Harden configuration (disable weak protocols, limit access).
โœ” Use TLS 1.2+ with strong ciphers.
โœ” Implement WAF & rate limiting to stop attacks.
โœ” Hide server headers & block bad bots.
โœ” Enable logging & monitoring for security events.

Cloud Linux Website #100GbE#100GbECloudNetworking#10GbE#40GbE#5GUPF#AdaptiveResync#AdaptiveResyncNVMe#AF_XDP#AIArbitrage#AIClusterOptimization#AIInferenceonFPGA#AIModelParallelism#AIonGPUs#AIQuantTrading#AMDMPGPU#AnsibleAutomation#AnsibleForVMware#ApacheFlinkPerformance#AWSNitro#AWSVMwareCloud#Azure#AzureVMwareSolution#BareMetalCloudTuning#BareMetalServer#BatchedInferenceOptimization#BladeServers#BSOD#CacheTiering#CentOS#CephHighPerformance#CiscoACI#CiscoACIAnsible#CiscoHyperFlex#CiscoMDS#CiscoNexus#CiscoUCS#CiscoVPC#CiscoVXLAN#CloudComputing#CloudHosting#CloudMigration#CloudNative5G#Colocation#ColumnarStorageTuning#CompressionOptimization#Containerization#CUDAonVMware#CyberSecurity#CyberSecurity #WindowsSecurity #PrivacyMatters #Firewall #EndpointSecurity#DataCenter#DataCenterNetworking#DDoSProtection#DebianServer#Deduplication#DeepLearningHFT#DeepLearningInfra#DellCompellent#DellIDRAC#DellIDRACAPI#DellOpenManage#DellPowerEdge#DellPowerMax#DellPowerStore#DellUnityXT#DellVxRail#DirectFlash#DirectMarketAccess (DMA)#DirectX#DistributedTrainingInfra#DPDK#DPDKTelcoOptimizations#DPUPassthrough#DPUvsFPGA#DruidRealTimeAnalytics#DVS#DynamicCongestionControl#eBPFNetworking#EdgeAIOptimization#EdgeComputing#EnterpriseIT#ESXi#ESXiAdaptiveResync#ESXiNUMAOptimization#ESXiQueueDepth#ESXiRDMA#ESXiTuning#ETLPerformanceOptimization#FCBufferCredits#FCNPIV#FCoE#FCoEPerformance#FCPortChannel#FibreChannel#FibreChannelZoning#Firewall#FPGAforAI#FPGAforHFT#GameOptimization#GlobalEdgeRouting#GoogleCloudVMwareEngine#GPUDirectStorage#GPUPassthrough#HardenedServer#HLSforFPGA#HPC#HPCforAI#HPE3PAR#HPEAlletra#HPEGen10Plus#HPEiLO#HPEiLOAutomation#HPEInfoSight#HPEOneView#HPEPrimera#HPEProLiant#HPEStoreOnce#Hyperscale#HyperscaleLoadBalancing#HyperscaleMultiTenantSecurity#HyperV#IDSIPS#InfiniBandAI#InfrastructureAsCode#IntelFPGAAcceleration#IntelSPDK#IntrusionDetection#IOPSOptimization#IOTailLatency#iSCSI#iSCSIJumboFrames#ITInfrastructure#ITPro#JuniperNetworks#K8sMultiCloud#KafkaUltraLowLatency#KernelBypassNetworking#KubernetesCluster#KVM#LatencyArbitrageInfra#LatencyFix#LinuxServer#LUNQueueDepth#ManagedHosting#MarketDataFeedOptimization#MarketMakingAI#MellanoxConnectXPerformance#MellanoxGPUDirect#MellanoxNetworking#MellanoxRoCE#Microsegmentation#Microservices#MIGonNVIDIA#MultiAccessEdgeComputing#NASStorage#NetAppAFF#NetAppAnsibleModules#NetAppFAS#NetAppFlexGroup#NetAppMetroCluster#NetAppONTAP#NetAppSnapMirror#Networking#NeuralAccelerators#NeuralNetworkBacktesting#NFVAcceleration#NSXT#NVGPUPassthrough#NVIDIABlueField#NVMe#NVMeLatencyBenchmark#NVMeoF#NVMeoFPerformance#NVMeOverFabric#NVMePolling#NVMeQueueDepth#NVMeTCPPerformance#NVSwitchTuning#O-RANOptimization#OnChipNetworking#OpenStack#OptanePMem#P4ProgrammableNIC#PCGaming#PCIssues#PensandoDPU#PersistentMemoryRDMA#PFCforRoCE#PicoSecondPrecision#PipelinedCompute#PowerShell#ProgrammableNICs#Proxmox#PureEvergreen#PureFlashArray#PureStorage#PureX90#PyTorchXLA (Accelerated Linear Algebra for PyTorch)#QoSStorage#RAID#RDMA#RDMAonDPU#RDMAOptimization#RDMAoverEthernet#RDMAQueueDepthTuning#RDMAStorage#RedHat#ReinforcementLearningForTrading#SANStorage#SentimentAnalysisTrading#Server#ServerlessPerformanceTuning#ServerRoom#ServerSecurity#SIEM#SIEMSolutions#SOC2Compliance#SRIOV#SRIOVNetworking#SSDServers#StorageClassMemory#StorageIOControl#StorageTiers#StreamingDataOptimization#StreamProcessingAI#SubMicrosecondTrading#SysAdmin#SysAdminLife#TaskScheduler#TCPBypass#TechSupport#TelcoEdgeAI#TensorFlowXRT#Terraform#TerraformMultiCloud#TerraformVMware#TickToTradeOptimization#TinyMLPerformance#UbuntuServer#UltraLowLatencyFPGA#vCloudDirector#VectorizedQueryExecution#VFIO#vGPUPassthrough#VMDirectPathIO#vMotion#VMware#VMwareHCX#VMwarePowerCLI#VMwarePVRDMA#VMwareSmartNIC#VPSHosting#vRANPerformanceTuning#vSANDeduplication#vSANPerformance#vSANResyncImpact#vSphere#vSphereMultiCloud#vSphereOptimization#WindowsAutomation#WindowsDebugging#WindowsFix#WindowsGaming#WindowsServer#WriteAmplification#WriteBackCaching#XilinxAlveo#XilinxSmartNIC#ZeroCopyNetworking#ZeroLatencyInference#ZeroTrustArchitecture#ZFSPerformanceTuning

Post navigation

Previous post
Next post

Related Posts

Step-by-Step Guide to Configuring TrueNAS CORE

March 31, 2025April 2, 2025

This guide will walk you through a detailed TrueNAS CORE installation and configuration, covering storage pools, networking, and services like SMB, NFS, and iSCSI. ๐Ÿ”น Step 1: Install TrueNAS CORE If you havenโ€™t installed it yet, follow these steps: Once installed, TrueNAS will display an IP Address on the console…

Read More
Linux

Anonymize Your Traffic With Proxychains & Tor: A Comprehensiveย Guide

January 21, 2025

In an era where digital privacy is increasingly under threat, individuals seek effective means to safeguard their online activities from prying eyes. One such powerful tool for anonymity is the combination of Proxychains and Tor. This blog post will guide you through the installation process on Linux, Mac, Windows, and…

Read More

Microsoft 365 Enterprise plans 2025

April 8, 2025April 8, 2025

Office 365 (now branded as Microsoft 365) offers several Enterprise plans tailored to the needs of medium to large organizations. These plans include a mix of productivity apps, security features, compliance tools, and collaboration services. Here’s a breakdown of the main Microsoft 365 Enterprise plans as of 2025: ๐Ÿ”น Microsoft…

Read More

Recent Posts

  • List of AD Schema Versions
  • OldNewExplorer Free Download For Windows 11, 10, 8 and 7 [Latest Version]
  • How to Get the Classic (old) Context Menu on Windows 11
  • BitLocker Recovery Keys
  • Active Directory and Server hardening

Recent Comments

No comments to show.
June 2025
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« May    
Log in
©2025 Tech Master | WordPress Theme by SuperbThemes
  • Login
  • Sign Up
Forgot Password?
Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.
body::-webkit-scrollbar { width: 7px; } body::-webkit-scrollbar-track { border-radius: 10px; background: #f0f0f0; } body::-webkit-scrollbar-thumb { border-radius: 50px; background: #dfdbdb }