Ok I'll try explain this as best I can. I've managed to setup to a subdirectory location /blog/
on the example.com
server block (Website A) that successfully displays my blog on the subdomain blog.example.com.au
server block (Website B), with the url as example.com/blog/
.
However when I click any of the links on the homepage from example.com/blog/
, it shows a 404 of Website A when it should link to an article on Website B.
Desired behaviour:
example.com/blog/article
links to blog.example.com/article
while displaying example.com/blog/article
Actual behaviour:
example.com/blog/article
links to example.com/article
while displaying example.com/article
404
I want to make sure /blog/
appears on every request to be passed to Website B through the /blog/
location block.
Here is my current server block for website A to serve the blog on website B:
server {
server_name example.com;
...
location ^~ /blog/ {
proxy_pass https://blog.example.com.au/;
proxy_set_header Host blog.example.com.au;
}
# This is needed to correctly serve static files for Website B and not have same 404 behaviour as explained above
location /assets/ {
proxy_pass https://blog.example.com.au/assets/;
}
# This is needed to correctly serve static files for Website B and not have same 404 behaviour as explained above
location /content/ {
proxy_pass http://blog.example.com.au/content/;
}
}
If it helps Website A and B are both reverse proxied and working perfectly on their own in the same conf file:
upstream Website_A {
server Website_A:8000;
}
upstream Website_B {
server Website_B:2368;
}
...