• Hey Everyone,

    I’m migrating an existing wordpress installation to a new server and placing the wordpress installation behind a reverse proxy.

    The reverse proxy is a NGINX server and the wordpress installation is also being put on a NGINX server. The 2 servers are individual VMs.

    I have the wordpress site working just fine, until I attempt to access the wp-admin pages. When I use the url https://www.example.com/wp-admin – I get a 301 redirect to https://<backend-server-fqdn>/wp-admin.

    What am I missing here? I managed to fix the issue by forcing $_SESSION[‘HTTP_HOST’] = <frontend-fqdn>;

    But this seems pretty hacky. I would imagine WP would allow for reverse proxy on its own.

    Any help or advice would be great!

Viewing 1 replies (of 1 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    WordPress is just an app on your server that generates URLs in the HTML and headers. If you need it to work on your reverse proxy then it may be easier to update your nginx config to modify those URLs.

    Here’s a config that works on my reverse nginx proxy. The part that needs work is the proxy_set_headers and the sub_filter lines.

    
    location ^~ {
    proxy_pass https://backend-server-fqdn;
    proxy_set_header Accept-Encoding ""; # no compression allowed or next won't work
    sub_filter 'https://backend-server-fqdn/' 'https://$host/';
    sub_filter '%3A%2F%2Fbackend-server-fqdn' '%3A%2F%2F$host';
    sub_filter_once off;
    }
    

    That should let you target the reverse proxy’s FQDN and just go.

    • This reply was modified 8 years, 2 months ago by Jan Dembowski. Reason: Added part about the URLs
Viewing 1 replies (of 1 total)

The topic ‘wp-admin redirecting to backend server from reverse proxy’ is closed to new replies.