Support » Networking WordPress » WordPress Multisite running on Apache2 behind Nginx Reverse Proxy

  • Hi everyone!

    I’ve got myself a blade server running in my garage, and wanted to help out a friend that needed to setup a multisite. I’ve done this a million times before so no biggie.

    The network is setup as such, because of only having one outgoing IP address:


    Turns out though, that when behind a reverse proxy, the WP installation has problems connecting to its own API as well as to, it only times out after a couple of seconds:
    (http_request_failed) cURL error 28: Resolving timed out after 10000 milliseconds

    The API is perfectly accessable from outside the host, as well as and it works perfectly as single site behind the proxy. So something about the multisite redirectioning I believe is wonky.

    This is the Nginx configuration on proxy (works on single site):

    server {
      listen 443 ssl http2;
      listen [::]:443 ssl http2;
      server_name THE_WORDPRESS_MULTISITE;
      ssl_protocols TLSv1.2 TLSv1.3;
      ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
      ssl_prefer_server_ciphers on;
      ssl_session_cache shared:SSL:10m;
      ssl_session_tickets off;
      ssl_certificate     /etc/letsencrypt/live/THE_WORDPRESS_MULTISITE/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/THE_WORDPRESS_MULTISITE/privkey.pem;
      gzip on;
      gzip_min_length 10240;
      gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
      gzip_disable "MSIE [1-6]\.";
      add_header Cache-Control public;
      location / {
    	proxy_pass http://THE_WORDPRESS_MULTISITE_IP:80;
    	proxy_set_header Host $http_host;
    	proxy_set_header X-Real-IP $remote_addr;
    	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    	proxy_set_header X-Forwarded-Proto $scheme;
    	proxy_set_header X-Forwarded-Server $host;
    	proxy_set_header Proxy "";
    server {
        if ($host = THE_WORDPRESS_MULTISITE) {
            return 301 https://$host$request_uri;
        server_name THE_WORDPRESS_MULTISITE;
        listen 80;
        return 404;
        return 301 https://$host$request_uri;

    This is the Apache config on the WordPress host (works on single site):

    <VirtualHost *:80>
    	DocumentRoot /var/www/wordpress
    	ErrorLog ${APACHE_LOG_DIR}/error.log
    	CustomLog ${APACHE_LOG_DIR}/access.log combined
            <Directory /var/www/wordpress>
                    Options Indexes FollowSymLinks
                    AllowOverride all
                    Order allow,deny
                    Allow from all

    This is the WP-CONFIG on the WordPress host:

    // ** Handle reverse proxy, passing the IP to the server.
    // ** This is used by some plugins to fetch the user's IP.
    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
      $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
      $_SERVER['REMOTE_ADDR'] = $ips[0];
    // ** Handle SSL reverse proxy
    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    [...] // Default WordPress configuration
    /* Add any custom values between this line and the "stop editing" line. */
    /* Multisite */
    define('WP_ALLOW_MULTISITE', true);
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', true );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );
    /* That's all, stop editing! Happy publishing. */
    [...] // Default WordPress configuration

    Can someone hint me towards a solution?

  • You must be logged in to reply to this topic.