Running a WordPress site involves managing performance, security, and scalability. While WordPress is a powerful platform, placing it behind a reverse proxy like Nginx Proxy Manager can significantly enhance its capabilities. This setup streamlines SSL certificate management, improves security by hiding your server’s IP address, and makes it easier to host multiple services on a single server. This guide will walk you through the entire process, from initial setup to final testing, ensuring you can confidently deploy your WordPress site behind Nginx Proxy Manager.
We will cover the essential prerequisites, provide detailed step-by-step instructions for installation and configuration, and share troubleshooting tips to resolve common issues. By the end of this article, you will have a secure, efficient, and professionally managed WordPress installation.
Why Use Nginx Proxy Manager with WordPress?
Before diving into the technical steps, let’s understand the benefits of this configuration.
- Simplified SSL Management: Nginx Proxy Manager provides a user-friendly web interface to issue and automatically renew free SSL certificates from Let’s Encrypt. This means no more complex command-line tools or manual renewals.
- Enhanced Security: A reverse proxy acts as a gateway to your WordPress site. It hides your server’s internal IP address, protecting it from direct attacks. You can also implement access control lists and other security measures at the proxy level.
- Centralized Domain Management: If you run multiple websites or services (like a blog, a forum, and a cloud storage service) on the same server, Nginx Proxy Manager allows you to route traffic to the correct application based on the domain name, all from one central dashboard.
- Improved Performance: Nginx is renowned for its ability to handle high volumes of traffic efficiently. It can also be configured to cache static content, which reduces the load on your WordPress server and speeds up page load times for your visitors.
Prerequisites
To get started, you will need a few things in place. This guide assumes you have a basic understanding of server management and Docker.
- A Server: A Virtual Private Server (VPS) or a dedicated server running a modern Linux distribution like Ubuntu or Debian.
- Docker and Docker Compose: Both must be installed on your server. Nginx Proxy Manager and WordPress are best run in containers for easy management and isolation.
- A Domain Name: You need a registered domain name (e.g.,
yourdomain.com) that you can point to your server’s public IP address. - DNS Configuration: You should have access to your domain’s DNS settings to create A records or CNAME records.
Step 1: Setting Up Nginx Proxy Manager
The first step is to install and run Nginx Proxy Manager (NPM). We’ll use Docker Compose for a simple and reproducible setup.
- Create a Directory: Create a dedicated directory for your NPM configuration.
mkdir nginx-proxy-manager cd nginx-proxy-manager
- Create a Docker Compose File: Inside this directory, create a file named
docker-compose.ymland add the following content. This file defines the NPM service, its database, and the necessary network configurations.version: '3' services: app: image: 'jc21/nginx-proxy-manager:latest' restart: unless-stopped ports: - '80:80' # Public HTTP Port - '443:443' # Public HTTPS Port - '81:81' # Admin UI Port volumes: - ./data:/data - ./letsencrypt:/etc/letsencryptNote: We’ve removed the separate database service for simplicity, as NPM’s default SQLite database is sufficient for most use cases. The network configuration is also simplified to use Docker’s default bridge network.
- Start Nginx Proxy Manager: Run the following command from within the
nginx-proxy-managerdirectory to download the images and start the containers.docker-compose up -d
- Access the Admin UI: Open your web browser and navigate to
http://<your-server-ip>:81. You will see the NPM login screen.
After logging in for the first time, you will be prompted to change your username, email, and password. Complete this step to secure your NPM instance. -
- Default Username:
[email protected] - Default Password:
changeme
- Default Username:
Step 2: Setting Up WordPress with Docker
With NPM running, it’s time to set up your WordPress site. We will again use Docker Compose to run WordPress along with its required MySQL database.
- Create a WordPress Directory: Navigate out of the NPM directory and create a new one for your WordPress site.
cd .. mkdir my-wordpress-site cd my-wordpress-site
- Create the Docker Compose File: Inside this new directory, create another
docker-compose.ymlfile with the following configuration.version: '3' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: your_strong_root_password MYSQL_DATABASE: wordpress MYSQL_USER: wordpress_user MYSQL_PASSWORD: your_strong_user_password wordpress: depends_on: - db image: wordpress:latest volumes: - ./wp-content:/var/www/html/wp-content restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress_user WORDPRESS_DB_PASSWORD: your_strong_user_password WORDPRESS_DB_NAME: wordpress volumes: db_data:IMPORTANT: Replace
your_strong_root_passwordandyour_strong_user_passwordwith secure passwords. Thewordpressservice does not expose any ports to the host machine. This is intentional, as all traffic will be routed through Nginx Proxy Manager. - Start WordPress: Run the following command to start your WordPress and database containers.
docker-compose up -d
Wait a minute or two for the containers to initialize completely.
Step 3: Configuring the Proxy Host in Nginx Proxy Manager
Now we connect the pieces. You need to tell Nginx Proxy Manager how to forward traffic from your domain to the WordPress container.
- Point Your Domain to Your Server: Go to your domain registrar’s DNS management panel. Create an A record for your domain (e.g.,
blog.yourdomain.com) and point it to your server’s public IP address. - Log in to NPM: Open the Nginx Proxy Manager admin UI at
http://<your-server-ip>:81. - Add a Proxy Host:
-
- Navigate to Hosts -> Proxy Hosts.
- Click the Add Proxy Host button.
- Fill in the Details Tab:
-
- Domain Names: Enter the domain you configured in your DNS (e.g.,
blog.yourdomain.com). - Scheme: Set to
http. - Forward Hostname / IP: Enter the name of your WordPress container. If you followed the steps above, this will be
my-wordpress-site_wordpress_1. You can find the exact name by runningdocker pson your server. - Forward Port: Enter
80. This is the internal port that the WordPress container listens on. - Enable
Block Common ExploitsandWebsockets Support: These are good default security and functionality settings.
- Domain Names: Enter the domain you configured in your DNS (e.g.,
- Configure SSL:
-
- Click on the SSL tab.
- In the SSL Certificate dropdown, select “Request a new SSL Certificate.”
- Enable “Force SSL” and “HTTP/2 Support.”
- Agree to the Let’s Encrypt Terms of Service.
- Click Save.
NPM will now request an SSL certificate for your domain and configure Nginx to proxy all traffic to your WordPress container. This may take a moment. Once complete, you should see the status change to “Online.”
Step 4: Finalize WordPress Installation and Testing
Your setup is almost complete. The final step is to run the famous WordPress 5-minute installation.
- Access Your Domain: Open your browser and navigate to your domain (e.g.,
https://www.bedpage.com/). You should be redirected to HTTPS automatically and see the WordPress installation screen. - Complete the Installation: Follow the on-screen prompts to select your language, set up your site title, and create your administrator account.
- Test Your Site: Once installed, log in to your WordPress dashboard and navigate your site. Ensure that all pages load correctly over HTTPS and that you can access the admin area without any issues.
Common Troubleshooting Tips
- 502 Bad Gateway Error: This usually means NPM cannot reach your WordPress container. Double-check that the “Forward Hostname / IP” in your Proxy Host settings matches the exact name of your WordPress Docker container. Also, ensure both NPM and WordPress containers are on the same Docker network if you are using custom networks.
- SSL Certificate Fails to Issue: This often indicates a DNS problem. Make sure your domain’s A record is correctly pointing to your server’s IP and has had enough time to propagate. NPM needs to be able to reach your domain over port 80 to verify ownership for Let’s Encrypt.
- “Too Many Redirects” Error: This can happen if WordPress is not aware that it’s behind a proxy. To fix this, you need to add the following lines to your WordPress
wp-config.phpfile. You can access this file by editing it directly on your host machine if you used a volume mount, or by usingdocker exec.if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { $_SERVER['HTTPS'] = 'on'; }This code tells WordPress to trust the
X-Forwarded-Protoheader sent by the proxy, resolving the redirect loop.
Conclusion: Take Control of Your Web Stack
You have successfully set up a robust and secure environment for your WordPress site. By placing it behind Nginx Proxy Manager, you’ve gained a simple interface for managing domains and SSL certificates while leveraging the power and security of a reverse proxy. This scalable setup not only protects your server but also prepares you to easily host more applications in the future.
This configuration is a professional standard used in many production environments. Now that you understand the process, you can confidently apply this powerful architecture to your own projects. Go ahead and start building something amazing on your newly fortified WordPress site.