Wordpress on Synology NAS with Nginx reverse proxy - Redirect Loop

July 27, 2019 140 views
Nginx WordPress Debian

Hello,
I am troubleshooting this for a long time now, but I can't find a solution by myself - hope you can help me.
I installed the Wordpress package on my Synology NAS, which serves Wordpress on http://192.168.0.101/wordpress

Now I want to access the site from the internet - therefore I set up a reverse proxy with Nginx - I use this proxy for some internal sites, everything works except Wordpress, where it ends either in an redirect loop, or a "page not found" Wordpress site.

Wordpress is hosted on the Synology Nas with no SSL, because I want that the SSL encryption is served by the reverse proxy, so that I don't need to install the certificate on the Synology Nas.

I already tried to disable Wordpress redirecting with
removefilter('templateredirect','redirect_canonical');
in the theme functions.php, but no success.

Thank you in advance for your much appreciated help!

My Wordpress website address is set to:
https://blog.mydomain.com/wordpress

My Nginx config for this subdomain part:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    index index.php;
    server_name blog.mydomain.com;

    # reverse proxy
    location / {
        proxy_pass http://192.168.0.101/wordpress/;
        include nginxconfig.io/proxy.conf;
    }

    # SSL
    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/mydomain.com/chain.pem;

    proxy_ssl_session_reuse on;
    proxy_ssl_verify       on;
}

#Forward HTTP to HTTPS

server {
   listen 80;
   listen [::]:80;
   server_name blog.mydomain.com;
   return 301 https://$server_name$request_uri;

}

NGINXCONFIG.IO proxy.conf

proxy_http_version  1.1;
proxy_cache_bypass  $http_upgrade;

proxy_set_header Upgrade            $http_upgrade;
proxy_set_header Connection         "upgrade";
proxy_set_header Host               $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-Host   $host;
proxy_set_header X-Forwarded-Port   $server_port;
1 Answer

Hello,

If you visit http://192.168.0.101/wordpress via your local network, does it work as expected?

If so, try updating the config a little bit to match your site and home URLs in your WordPress installation:

    # reverse proxy
    location /wordpress {
        proxy_pass http://192.168.0.101/wordpress/;
        include nginxconfig.io/proxy.conf;
    }

Let me know how it goes!
Bobby

Have another answer? Share your knowledge.