DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk11 min

How to Harden WordPress Security on an Nginx Server

A practical, defense-in-depth guide to securing WordPress on Nginx, including PHP-FPM rules, non-executable uploads, HTTPS and proxy handling, brute-force controls, and recovery testing.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Harden WordPress on Nginx in layers: run supported software, keep the Nginx-to-PHP-FPM boundary narrow, prevent PHP execution in upload directories, deny sensitive files, enforce HTTPS for administration, protect secrets, slow automated logins, and maintain tested backups and logs. Nginx is only one part of the control set; a secure configuration still needs updates, strong authentication, careful permissions, and recovery procedures.

The sequence below is designed for a self-managed Nginx server. Adapt paths, PHP-FPM socket names, proxy addresses, and rate limits to your deployment, then validate every change with nginx -t before reloading.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Inventory the stack before changing rules

Write down the operating system, Nginx release, PHP and PHP-FPM release, database engine and version, WordPress version, enabled plugins and themes, TLS termination point, document root, scheduled jobs, and backup destinations. Security work is easier when you know which service owns each request and which component must be patched.

Use supported platform versions

The current WordPress requirements page recommends PHP 8.3 or newer, MariaDB 10.11 or newer or MySQL 8.0 or newer, and HTTPS. Older PHP and MySQL branches can be end-of-life, which means known fixes may no longer be available from their maintainers. Confirm that your operating system repositories provide security updates for the exact versions you run; do not assume that an old distribution package is safe merely because it still starts.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
  • Record the installed versions and their vendor support status.
  • Update WordPress core, plugins, themes, PHP, the database, Nginx, and the operating system through a planned maintenance process.
  • Remove unused plugins and themes instead of leaving abandoned code enabled.
  • Take a restorable backup before major updates and verify the site afterward.

WordPress supports Nginx, and large WordPress installations use it successfully, but support for the web server does not make an unrestricted configuration safe.

2. Build a narrow Nginx-to-PHP-FPM boundary

Nginx should send only intended PHP scripts to PHP-FPM. Do not use a broad rule that treats every requested file as PHP, and do not copy Apache .htaccess rules into an Nginx configuration. Nginx does not read .htaccess; equivalent restrictions belong in the server or location blocks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the document root and front-controller fallback

Replace the example path with the real directory that contains wp-admin, wp-content, and wp-includes:

server {
    listen 443 ssl http2;
    server_name example.com www.example.com;
    root /var/www/example.com/public;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ .php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
}

try_files $uri =404 prevents a request for a nonexistent script from being handed to PHP-FPM. The socket name must match the PHP-FPM service installed on your server. If you use a TCP upstream instead of a Unix socket, define that upstream explicitly and restrict access to it.

Protect the configuration file

Add an exact match for wp-config.php so a mistake elsewhere cannot expose it as a downloadable file:

location = /wp-config.php {
    deny all;
    access_log /var/log/nginx/wp-denied.log;
    log_not_found on;
}

When practical, place wp-config.php one directory above the public document root, where WordPress can still load it. On the filesystem, allow only the owner and the web-server account or group to read secrets, and check ownership after updates. Permissions that are too open expose database credentials; permissions that are too restrictive can break updates or scheduled tasks.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Deny hidden files and executable uploads

Attackers routinely probe for repository metadata, backup files, password files, and accidentally published operating-system artifacts. Deny dot-files while allowing the ACME challenge directory if your certificate automation needs it:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
location ~ /.(?!well-known).* {
    deny all;
    access_log /var/log/nginx/wp-denied.log;
    log_not_found on;
}

This blocks files such as .htaccess, .htpasswd, .git content, and .DS_Store. Review the exception before enabling it on a site that deliberately publishes another hidden path.

Make uploads data, never server code

Media directories should deliver images, documents, and other permitted data; they should not execute PHP. WordPress commonly stores uploads below wp-content/uploads. Multisite installations may also use a files path. Deny PHP requests in both locations:

location ~* ^/wp-content/uploads/.*.php$ {
    deny all;
    access_log /var/log/nginx/wp-denied.log;
    log_not_found on;
}

location ~* ^/files/.*.php$ {
    deny all;
    access_log /var/log/nginx/wp-denied.log;
    log_not_found on;
}

Keep these locations alongside, and before testing, the general PHP location. A denied request should remain visible in an access log; those events can feed alerting or fail2ban-style controls. Do not silently discard them, because repeated probes are useful evidence.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Also inspect writable directories created by plugins. If a plugin requires a special executable endpoint, document that exception and limit it to the exact path instead of enabling PHP throughout the directory.

4. Enforce HTTPS correctly

Redirect clear-text requests

Use a separate port-80 server that redirects to the canonical HTTPS host:

server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}

Configure a valid certificate on the 443 server and test both the public site and administrative URLs. HTTPS must cover login credentials, cookies, and the dashboard, not just the home page.

Force secure administration in WordPress

Add this constant to wp-config.php:

define( 'FORCE_SSL_ADMIN', true );

Use the canonical HTTPS URL in the WordPress and Site Address settings. Check that login, logout, password reset, media uploads, the REST API, cron callbacks, and embedded assets remain on HTTPS after the change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Add HSTS only when the whole scope is ready

HSTS tells browsers that honor it to use HTTPS automatically. Enable it only after every intended subdomain, redirect, API endpoint, and operational service is available over HTTPS. A typical one-year policy is:

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

Treat that duration as an operational choice, not a prerequisite for WordPress. Once browsers cache HSTS, an incorrectly configured subdomain can become inaccessible over HTTP until the policy expires or is removed from the browser.

5. Handle a reverse proxy without redirect loops

In a CDN or load-balancer deployment, TLS may terminate before the request reaches Nginx. The proxy must pass the original scheme, commonly in X-Forwarded-Proto, and Nginx or WordPress must use it consistently. If WordPress believes an HTTPS request is HTTP, it can generate insecure URLs or redirect repeatedly.

Trust only your controlled proxy path

Configure the proxy to overwrite, not append to, the scheme header supplied by an untrusted client. On the origin, accept that header only from the proxy addresses or private network you control. Do not make every internet client authoritative for whether a request was encrypted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pass the value through the PHP boundary when your architecture requires it:

location ~ .php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}

WordPress can translate a trusted HTTPS indication for its own request handling. A common wp-config.php pattern is:

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
    $_SERVER['HTTPS'] = 'on';
}

Use this only when the header is guaranteed to come from your controlled proxy. Test the origin directly, through the proxy, and through any health-check path, then check redirects and generated canonical URLs.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

6. Reduce login and brute-force abuse

Strengthen accounts first

  • Give every administrator a long, unique password that is not reused elsewhere.
  • Enable two-step authentication for administrator accounts.
  • Use separate accounts for administration, publishing, and routine reading, with the least privilege each task needs.
  • Remove dormant users and review administrator membership regularly.
  • Restrict dashboard access by network or VPN when your organization can do so without blocking legitimate operations.

Apply measured Nginx rate limits

Nginx can slow repeated requests to login endpoints. The following is an example starting point, not a universal safe rate:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
http {
    limit_req_zone $binary_remote_addr zone=wp_login:10m rate=1r/s;

    server {
        location = /wp-login.php {
            limit_req zone=wp_login burst=5 nodelay;
            limit_req_status 429;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        }
    }
}

Place the zone definition in the http context and tune the rate and burst from your traffic pattern. A shared office, mobile carrier, or IPv6 network can put many legitimate users behind one address. Monitor 429 responses before tightening the policy.

XML-RPC may be required by mobile apps, publishing clients, or integrations. If you rate-limit or restrict /xmlrpc.php, inventory those clients first and test them after the change. Blocking it blindly can break legitimate workflows; leaving it unrestricted can provide an attractive automated endpoint.

Use a server-layer rule set when appropriate

A web application firewall or ModSecurity deployment with the OWASP Core Rule Set can detect and block common malicious patterns before they reach WordPress. Treat signatures as a managed control: run in detection mode while tuning, review false positives, and keep the rule set updated. A WAF does not replace patching, authentication, or secure file permissions.

7. Disable high-risk administration features

WordPress includes a dashboard editor that can write plugin and theme PHP. Disable it so a stolen administrator session cannot immediately edit executable code:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
define( 'DISALLOW_FILE_EDIT', true );

This does not prevent all file writes performed by plugins or deployment tooling. Keep plugin and theme installation under a controlled process, and avoid granting the web-server account broad write access to the entire document root. Test updates in a staging environment or maintenance window, because incorrect ownership can make legitimate updates fail.

Protect database credentials and salts in wp-config.php. Store secrets outside version control, audit who can read them, and rotate them when an administrator leaves or a backup is exposed.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Keep logs useful and actionable

Retain Nginx access and error logs, PHP-FPM logs, WordPress activity signals available in your environment, and authentication events. Include denied hidden-file and upload-PHP requests in a log that your monitoring system can search. Review spikes in requests to wp-login.php, xmlrpc.php, unusual status codes, new administrator accounts, and unexpected changes under wp-content.

Set retention according to your incident-response and privacy requirements. Forward copies to storage that an intruder who compromises the web account cannot erase. Alerts should identify the host, path, source address or proxy identity, status code, and time window so an operator can decide whether to block, investigate, or restore.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

9. Back up for recovery, not just compliance

Maintain independent backups of the database, uploaded media, themes, plugins, and configuration secrets. Keep at least one copy outside the web server and protect backup access with separate credentials. The appropriate frequency and retention depend on your recovery-point objective: a busy publishing site may need more frequent database copies than a rarely changed brochure site.

Test restoration separately

  1. Restore a backup into an isolated environment.
  2. Verify that the database, media, plugins, themes, and configuration agree on the site URL.
  3. Run the application through HTTPS and test login, publishing, media delivery, REST requests, and scheduled jobs.
  4. Record how long recovery took and update the runbook while the steps are fresh.

A backup that has never been restored is an assumption, not a recovery plan. Keep forensic copies when investigating compromise rather than overwriting the only evidence with a rushed restore.

10. Choose the operating model that fits your team

There is no universal best place to enforce every control. Decide who will patch, tune, observe, and recover the site.

Control area Self-managed Nginx Managed WordPress hosting Front-end WAF or CDN
Server configuration You control Nginx, PHP-FPM, filesystem permissions, and network policy. The host controls much of the server; confirm which directives and PHP settings are available. It filters traffic before the origin but does not replace secure origin configuration.
Updates and patching Your team schedules and verifies operating-system, Nginx, PHP, database, WordPress, plugin, and theme updates. The provider may handle some layers; establish exactly what is included and what remains yours. It can update detection rules, but origin software and WordPress code still require maintenance.
Logs and visibility You can retain Nginx, PHP-FPM, system, and application logs according to your policy. Visibility depends on the host’s export and retention features. You gain edge request data, but must still retain origin logs for complete diagnosis.
Backups and recovery You choose destinations, retention, encryption, and restoration tests. Ask how often backups run, how long they are retained, and whether restores are operator-assisted. Traffic filtering is not a backup; maintain independent origin and database copies.
Rate limiting and bots Use Nginx limits, fail2ban-style automation, or a WAF you operate. Use the controls exposed by the host and verify their effect on login, REST, XML-RPC, and multisite traffic. Edge controls can absorb or challenge abusive requests before they reach the server.
TLS and HSTS You configure certificates, redirects, proxy headers, and HSTS readiness. The host may automate certificates; verify renewals, redirects, and subdomain coverage. The edge may terminate TLS, but the origin and forwarded-scheme handling must remain correct.
Compatibility You can tune rules for plugins, REST API clients, XML-RPC consumers, and multisite, but you own the testing. Compatibility depends on platform restrictions and support processes. Strict bot or firewall rules can block legitimate API and publishing clients unless exceptions are tested.

Evaluate total operating cost in staff time, support, backups, and incident recovery rather than looking only at a hosting line item. Ask for evidence of the controls you actually need instead of assuming that a product label implies them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

11. Validate safely after every change

  1. Save a known-good Nginx configuration and a current backup.
  2. Run sudo nginx -t. Do not reload if the test reports an error.
  3. Reload during a controlled window with sudo systemctl reload nginx.
  4. Request the home page, representative permalinks, a static asset, and a nonexistent URL.
  5. Open /wp-login.php and /wp-admin/ over HTTPS, then confirm that an HTTP request redirects.
  6. Test a media upload and download; confirm that a harmless PHP-named file in uploads is denied rather than executed.
  7. Exercise the REST API, any XML-RPC-dependent client, cron, and multisite paths if they are enabled.
  8. Test through the reverse proxy and, where safe, from the origin network to detect scheme or trust mistakes.
  9. Review access, error, and PHP-FPM logs for unexpected 4xx, 5xx, redirect loops, or permission failures.

Keep a change record containing the reason, exact directive, test results, and rollback command. Environment-specific testing matters because a rule that is safe for a single-site install can break a plugin, API client, or multisite path.

12. A practical hardening checklist

  • Supported WordPress, PHP, database, Nginx, and operating-system releases are installed.
  • PHP requests go only to PHP-FPM, with nonexistent scripts rejected.
  • Hidden files, wp-config.php, and other secrets are denied or kept outside the public root.
  • PHP execution is denied below uploads and multisite file directories.
  • HTTP redirects to HTTPS, administrative sessions require HTTPS, and proxy scheme handling is tested.
  • HSTS is enabled only after every covered hostname is HTTPS-ready.
  • Passwords are unique, two-step authentication is enabled, and privileges are minimized.
  • Login and, where compatible, XML-RPC abuse is rate-limited or filtered.
  • The dashboard file editor is disabled and filesystem ownership is reviewed after updates.
  • Access and error logs are retained, monitored, and protected from tampering.
  • Independent backups exist and restoration has been rehearsed.
  • Every Nginx change has passed nginx -t and functional tests.

The Bottom Line

A hardened WordPress-on-Nginx deployment is a maintained system, not a single rewrite rule. Keep the PHP boundary restrictive, make uploads non-executable, enforce and correctly detect HTTPS, limit abusive authentication traffic, protect configuration and editing paths, and prove that logs and backups work before an incident occurs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.