• Resolved Almamu

    (@almamu)


    Hi everyone!

    I’ve recently set up apache2 and nginx to work together so nginx can serve static files while apache2 does the PHP processing, everything seems to work okay with a phpBB forum I have on the same server, but I’m having a hard time to get WordPress working without issues. Following some guides on this forum I’ve managed to access the backoffice, but the site keeps redirecting to itself in an infinite loop. This is what I’ve added to wp-config.php to enable backoffice again:

    define('FORCE_SSL_ADMIN', true);
    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
            $_SERVER['HTTPS'] = 'on';

    The nginx configuration is relatively simple:

    server {
            listen 443 ssl;
    
            root /var/www/webroot;
            index index.php index.html index.htm;
    
            server_name domain.com www.domain.com;
    
            location / {
                    try_files $uri $uri/ /index.php;
                    include /etc/nginx/expires.conf;
            }
    
            location ~\.php$ {
                    proxy_redirect off;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $remote_addr;
                    proxy_set_header Host $host;
                    proxy_set_header X-Forwarded-Proto https;
                    proxy_pass https://127.0.0.1:8080;
            }
    
            location ~/\.ht {
                    deny all;
            }
    
            include /etc/nginx/ssl.conf;
    }

    And apache2 has a simple virtualhost too:

    <VirtualHost 127.0.0.1:8080>
            ServerAdmin [email protected]
            ServerName domain.com
            ServerAlias www.domain.com
    
            DocumentRoot /var/www/webroot
            <Directory />
                    Options FollowSymLinks
                    AllowOverride All
            </Directory>
            <Directory /var/www/webroot>
                    AllowOverride All
            </Directory>
    </VirtualHost>

    Everything works fine if I only use apache2 and enable SSL support, but I want to use nginx as its way faster for static content. I’m using the latest WordPress version in a clean 4.2.2 installation, with 4 plugins that I had already installed before configuring nginx and were working flawless:
    -Akismet
    -Captcha by BestWebSoft
    -Coming soon and Maintenance mode WpDevArt
    -Google Analytics Dashboard for WP

    Every plugin is up to date. I’ve tried installing a new WordPress with no luck, same problem. Any ideas of whats wrong with this config or a way to solve it? I’m completely out of ideas now, tried lots of things today… Thanks in advance

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Redirection loop on site – nginx as apache's reverse proxy and SSL’ is closed to new replies.