0

I'm trying to serve a wordpress blog from another domain using proxy_pass.

https://blog.domain.example/

to

https://domain.example/blog

I clearly also want to rewrite all the urls accordingly. What I did:

location  /blog {
  rewrite /blog(.*)  /$1  break;
  proxy_pass         https://blog.domain.example/;
  proxy_redirect     off;
  proxy_set_header   Host $host;
}

Right now it's serving a completely white page and curl -i tells me that "HTTP/1.1 404 Not Found". Just to complete the information: https://blog.domain.example is using a certificate, https://domain.example another certificate. Can this be the root cause of the problem?

How can I fix this? Thanks in advance.

ngw
  • 1,261
  • 3
  • 13
  • 15
  • Why are you trying to do this? It's going to be bad for SEO, make your nginx configuration needlessly complicated, and perhaps other things. Not to mention you'll also have to hack on WordPress because it has its own internal URLs embedded everywhere. – Michael Hampton Jul 30 '18 at 12:44
  • On what basis you say this? That is actually going to be much better for SEO, all backlinks to the blog are going to give link juice to the main domain instead of the blog subdomain. No hack on Wordpress either, just change the blog url from inside Wordpress admin. – ngw Jul 30 '18 at 14:38
  • You need to change the blog URL in WordPress and do 301 redirects. What you propose to do above will result in the duplicate content penalty. – Michael Hampton Jul 30 '18 at 15:23
  • How can it result in duplicate content if it's not even linked for starters? – ngw Jul 30 '18 at 15:58
  • None of this is really on the question I made anyway – ngw Jul 30 '18 at 15:59
  • Your proposed config will cause each post and page in WordPress to appear at two distinct URLs, thus duplicate content. Again, you're supposed to be doing a 301 redirect. And I'm quite aware it's not the question you asked. That's because actually answering the question you asked would not help you but harm you. – Michael Hampton Jul 30 '18 at 16:12
  • Oh I get your point now, fair enough. I’m just trying to proxy pass on my staging, everything is behind http auth as I just want to test the conf. On that nginx I just need to serve the content and not perform the actual redirect which has to be done on the blog.domain.example server. Don’t worry about that, my question was purely technical, the whole thing is in the hands of a seo. – ngw Jul 30 '18 at 21:24

0 Answers0