Up to $100 off Dedicated Servers

Configuring NGINX for Managed WordPress

Posted on by Libby White | Updated:
Reading Time: 2 minutes

Running a WordPress site can be incredibly simple and used right out of the box, but you may need to customize or add specific files in order to get the most out of your site. Our Managed WordPress customers can include custom NGINX configurations for individual sites because we know that adding simple redirects or adjusting browser cache settings are actions that many of our Managed WordPress users do on a regular basis. Read on to learn how you can use this functionality for your own site.

On the Managed WordPress platform, custom configuration files are read from the NGINX folder within the site’s home directory. Any file ending with .conf will be read into NGINX on reload or restart, so a file called ~/nginx/user.conf.sample is provided as a placeholder.

While you can create and edit these files, it is necessary that you reach out to our Managed WordPress Support team to reload the NGINX configuration. This will allow us to test the file configuration and confirm that there are no errors or warnings. Because your site performance and uptime is important, the Managed WordPress support team will manually review files to check for potentially irregular and harmful configurations.

Although the primary use of this feature is for configuring redirects at the NGINX level. you may also set custom browser cache expiration times for static files. Any configurations beyond those described below are considered beyond scope support.

An example of simple redirects is below.

# Simple redirect to an individual page
location /example-redirect-123 {
add_header X-Redirect-By "Yoast SEO Premium";
return 301 /example-redirect;

# Rewrite all urls under an old path to a new path
location /category/old-category {
rewrite ^/category/old-category/(.*)$ /category/new-category/$1 permanent;

This is an example of adjusting browser cache settings.

# Reduces js and css cache times to a single day instead of the MWP default of 1 year.
location ~* \.(?:css|js)$ {
expires 24h;
access_log off;
add_header Cache-Control "public";

If you are looking to block access to a specific directory, you can complete this request by using the following command.

rewrite ^/wp-content/private_directory/(.*) /last;

Where private_directory is the directory you wish to block access to.

Configuring NGINX

1. Log into the site via SSH.


2. Navigate to the NGINX directory located in the home directory.

s150@default:~$ pwd
s150@default:~$ cd nginx
s150@default:~ngingx$ ls

3. Create a file ending in .conf.

s150@default:~/nginx$ touch redirects.conf
s150@default:~ngingx$ ls
redirects.conf user.conf.sample

In this example, we are using redirects.conf, but you can name it anything you’d like, just make sure you remember the file name.

4. Modify the file with the configuration changes.

s150@default:~/nginx$ vi redirects.conf
s150@default:~ngingx$ cat redirects.conf
# Limited to directives valid in the server block context
# All files ending in '.conf' in this directory will be loaded
# Please contact support to have them reload the nginx config files
# for changes to go into effect.# Configure redirects
location /example-redirect-123 {
add_header X-Redirect-By "Yoast SEO Premium";
return 301 /example-redirect;

5. Contact support to request review and reload of the config.

Avatar for Libby White

About the Author: Libby White

Former technical writer for Liquid Web. When Libby is not writing for work, she spends time learning more about digital & technical writing, web development, hanging with her family, and taking photographs with her Nikon. Always learning, always growing, never stopping.

Latest Articles

How to renew an SSL certificate (a paid SSL cert)

Read Article

How to use NextCloud — setup and features

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article