3

I have a Server-a which only contains a Nginx and a node application in execution.

However, I want to serve the Node app from that server, which is also serving an Angular application.

But when I navigate to server-a/blog, I want to make a reverse proxy (internal proxy) to a different server (Server-b), which contains a Wordpress setup, also with a Nginx.

So, always I navigate to server-a/blog, serves the content of the server-b

I have it partially working with this configuration:

    proxy_buffering on;
    proxy_buffer_size 1k;
    proxy_buffers 24 4k;
    proxy_busy_buffers_size 8k;
    proxy_max_temp_file_size 2048m;
    proxy_temp_file_write_size 32k;



    location /blog/en/ {
        try_files $uri @proxy;
    }

    location @proxy {
        proxy_redirect off;
        proxy_set_header X-Forwarded-Host "$host";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://server-b;
    }

But what happens is: If I navigate to server-a/blog/wp-admin, I get an instant redirection to server-a/wp-admin.

All the relative links on the Wordpress installation must be accordingly with the server-a URL.

This is the setup I have on my Wordpress DB setup:

    +-----------+-------------+-----------------------+----------+
    | option_id | option_name | option_value          | autoload |
    +-----------+-------------+-----------------------+----------+
    |         1 | siteurl     | http://server-a/blog/ | yes      |
    |         2 | home        | http://server-a/blog/ | yes      |
    +-----------+-------------+-----------------------+----------+

1 Answer 1

0

This is almost certainly due to the different types of relative urls.

According to http://www.webreference.com/html/tutorial2/3.html

A directory called .. (two periods) in a relative URL indicates the parent directory, essentially stripping off everything up to the previous slash in the the Base URI. Note that this only has meaning inside the pathname, so you cannot use this notation to go up higher than the root directory.

A directory called . (one period) refers to the current directory.

A relative URL that begins with / (a slash) always replaces the entire pathname of the base URL.

A relative URL that begins with // (two slashes) always replaces everything from the hostname onwards.

Thus a relative url that does "/wp-admin" will replace the entire base as you're experiencing. You want it to be replaced with "./wp-admin" so that it won't rewrite the whole thing.

As for actually changing it, I'm not sure, but I suspect you'll need to change it on the wordpress side.

1
  • Yes, I know about that. Unfortunately that won't fix my issue, as I after I done some research I noticed could be the case that Wordpress is doing some sort of redirection.
    – daminufe
    Sep 21, 2016 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.