2

I have a website https://www.winni.in running in tomcat which is behind nginx and I also have a blog in wordpress which has url https://www.winni.in/blog both these are located on same machine in aws ec2

Due to some reason I want wordpress blog to be located on a separate ec2 instance which is also running nginx. But I don't want to change the url to subdomain like blog.winni.in, is there any way to do this? By which I can run blog on separate ec2 instance but keep using url as winni.in/blog?

3
  • Use CloudFront. Alternatively you can proxy the requests from the first machine to the new one. Dec 8 '15 at 8:53
  • How cloudfront would help? Could you please elaborate little bit
    – Abhi
    Dec 8 '15 at 11:27
  • You can create a distribution that has multiple origins, each one having a different folder to serve. Dec 8 '15 at 11:41
2

You can use an Proxy in Nginx:

location / {
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   Host      $http_host;
    proxy_pass         http://YOURTOMCATSERVER:{PORT};
}

location /blog {
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   Host      $http_host;
    proxy_pass         http://YOURBLOGSERVER:{PORT};
}
1

You can consider using Nginx as a Reverse proxy for Tomcat & wordpress.

Add a seperate location tag for /blog/ & proxy pass that traffic to your new wordpress ec2 server. This will make sure that your URL stays at http://winni.in/blog/ & configure siteurl in wordpress to be http://winni.in and your nginx server's hosts file needs to make below entry

newEC2IPaddress winni.in

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