Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Currently my blog is hosted at blog.domain.com and is hosted on a LAMP stack and running wordpress. This is where I have the blog.domain.com DNS a record point to.

I also have domain.com hosted on an nginx server and is going to run my ecommerce app (magento). The domain.com dns a record points here. We put both applications on sepparate servers for security reasons.

I wanted to move the blog to domain.com/blog for seo reasons. What I did was set up a reverse proxy with nginx as a frontend cache for the apache/wordpress backend. So this is working beautifully and I have noticed the caching is really improving my load times.

Now I need to redirect all my blog.domain.com requests to domain.com/blog. But what is the best approach? Should I change the dns a record for blog.domain.com to my nginx server and then have nginx process the rewrite/redirect? Or should I put the rewrite on the apache server? I only have access the the .htaccess file on the Apache server.

I haven't ever done this so I thought I'd ask the community what is the best approach for situations like this.

Thanks

share|improve this question
    
I think it would be good practise to have the A record point to the right server. Then rewrite the blog URL, or just proxy the blog URL to the real url of the blog. That way the url does not change for your users. –  Isaac Feb 5 '13 at 17:22
    
So you are saying keep the a record for blog.domain.com pointed to the LAMP stack server that actually runs wordpress? Then to do an internal rewrite on that server for any blog.domain.com/?request requests to domain.com/blog/?request, which then actually bounces back to Nginx since it is hosting domain.com, and then finally it will reverse proxy the request to the LAMP wordpress server that runs blog.domain.com and display the content? Thanks for the help! Just wanna make sure I understand. –  thindery Feb 5 '13 at 21:09
1  
Ok, I think I missunderstood your question. If your nginx, which serves your magento, is also a reverse proxy for your LAMP Server, then the A record should point there. Because from the outside, your site "lives" there, its not relevant that its just a proxy. –  Isaac Feb 6 '13 at 7:34
    
Thanks for the clarification. That makes sense. –  thindery Feb 6 '13 at 14:25

1 Answer 1

You have two options:

Option 1: Keep the DNS as is.

  • Setup a redirect on Apache.
  • Make sure to exclude your reverse proxy so it doesnt get redirected to itself.
  • Advantage is that this is less effort.

Option 2: Move stuff around.

  • Create an additional A record, say blog-backend.example.com pointing to the server actually hosting the blog (Apache)
  • Change the reverse proxy settings to point to blog-backend.example.com
  • Configure Nginx on example.com to handle blog.example.com and redirect it to example.com/blog
  • Change the DNS for blog.example.com. so it points to the same server as example.com. (Nginx)
  • Change firewall on blog-backend (apache) so it only accepts requests from Nginx.
  • Still need to keep the blog-backend server, so the blog will be isolated from the e-commerce site.
  • More effort, no real payoff
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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