WordPress.org

Ready to get started?Download WordPress

Forums

Reverse Proxy and Permalinks (7 posts)

  1. independence
    Member
    Posted 5 years ago #

    Hello

    I've been using WordPress behind a ReverseProxy for a while. It works pretty Ok after modifying the base URL in the database and disabling the CanonicalURL function in the sourcecode. However, I can't seem to get Permalinks to work.

    The setup is like this:
    independence.mydomain.com/blog/ is passed via the proxy into the backend server which recieves a request like this: mydomain.com:8080/~independence/blog/

    If I enable Permalinks in WordPress, it writes a .htaccess file like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    # END WordPress

    This does not work on my setup since /blog/ is not in the root, but actually in /~independence/blog/, so I rewrote it like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~independence/blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /~independence/blog/index.php [L]
    </IfModule>
    # END WordPress

    Now the rewrite seems to work fine, but WordPress can't figure out which pages to load. I just get messages like "This page does not exist" instead of the actual content on any page. The menu/sidebar etc loads fine however.

    I've been looking around a bit in the sourcecode, wp-includes/rewrite.php for example, but I can't find the place where the interpretation of the URL is done. Has anyone else got this working?

  2. independence
    Member
    Posted 5 years ago #

    Anyone?

  3. vbit
    Member
    Posted 5 years ago #

    I had nearly the same problem, here are my 2 cents:
    It wasn't so easy to determine which path was finally searched by WordPress at the end (I probably had to active Apache rewriting logs to find out... it's a bit far now)

    Finally I fixed the problem with a symbolic link (on Unix system) named "blog" in my "blog" htdocs base directory.
    Perhaps it's easier to show the commands than to explain:
    my url is http://www.domain.com/blog/ proxying to localhost:8080/ and I did
    $ cd <path>/blog (that is the DocRoot of my Apache virtual host)
    $ ln -s blog .

    Perhaps for you it will be a bit different because you have "~independence/blog" instead of "blog"
    Try
    a blog link at same level than you independence_dir (htdocs DocRoot) if possible (but looks like automatic web user dir..)
    or
    <>/independence_dir/blog/~independence/blog -> <>/independence_dir/blog )

    Having the final filepath wordpress is searching for will help you to guess what to do.

    Anyway be careful, it's quite dangerous because it can generate loops on some operations like if you try to copy the dir without special options!

    I must say that the WP url rewriting features are still problematic when used in a complex web architecture like reverse-proxy.

  4. independence
    Member
    Posted 5 years ago #

    Hm, okay. I tried that thing with a symlink, it solved an issue where WordPress adds an additional "/~independence/blog" when you click on previous entries in the blog. After a couple of clicks you end up with a URL like "/~independence/blog/~independence/blog/~independence/blog/~independence/blog/index.php?blabla" however, which looks really really ugly IMO. I wish there was some better way to do this...

    If any WordPress devs are reading this, I'm happy to set you up with an account on my box so you can try this yourself. I'm guessing this setup with a reverse proxy is not that common, so maybe it's hard to test. You can use .htaccess files etc on my box if you need to. Just send me an email at independence at blinkenlights dot se if you're interested! :)

  5. justsomeguyinla
    Member
    Posted 4 years ago #

    I have a reverse proxy in front of my wordpress site. I hack wordpress files to make it work. I do things a little differently, but you can probably get by following the instructions in this post:

    http://wordpress.org/support/topic/210149

  6. justsomeguyinla
    Member
    Posted 4 years ago #

    Actually after digging around and some testing, I got wordpress to work without modification behind my reverse proxy by adding the following directive to my virtual host configuration (on the backend server):

    RequestHeader set Host http://www.example.com

    You will need to have mod_headers enabled for this directive to be recognized.

  7. bernhard-reiter
    Member
    Posted 4 years ago #

    I found a WordPress-plugin based solution I posted here (as part of a different error topic):

    I'm running WordPress under somewhat complex conditions ("reverse proxy") causing my wordpress installation to be located at "http://myuni.ac.at/mydir" (==siteurl) and to be reached with a browser via "http://mydomain.at" (==home). This requires me to use the "Redirection" plugin with a regexp pass-through rule redirecting
    ^/mydir/(.*)
    to
    /$1

    Works quite well; the plugin required is found here.

Topic Closed

This topic has been closed to new replies.

About this Topic