I’ve obtained a WordPress app working on Apache (on weblog.instance.com), and an Nginx server that works as a reverse proxy (on instance.com). My essential purpose is to have weblog.instance.com accessible by means of instance.com/weblog. I’ve achieved this.
My secondary purpose is to have weblog.instance.com not accessible anymore, and to redirect requests on to weblog.instance.com to instance.com/weblog. This I have not been in a position to obtain.
My concept was to make use of X-Forwarded-Host headers for this, however a) I do not know if that is the precise method, and b) I can not get this to work. My setup is as follows:
Nginx config:
rewrite ^/weblog$ https://instance.com/weblog/ everlasting;
location ^~ /weblog/ {
proxy_set_header Forwarded dev.instance.com;
proxy_set_header Host weblog.instance.com;
proxy_pass https://weblog.instance.com/;
}
Apache config:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Host} !^dev.instance.com$ [NC]
RewriteRule /?(.*)$ https://instance.com/weblog/$1 [R=301,L]
</IfModule>
This setup accurately performs a reverse proxy (aka, if I’m going to instance.com/weblog, I will see the contents of weblog.instance.com). Nonetheless if I’m going to weblog.instance.com, I am not redirected. Moreover I do not know find out how to debug this, because the X-Forwarded-Host header isn’t seen in any net improvement instruments I take advantage of so far as I do know.
Any and all assistance is welcome, thanks upfront!