PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, June 25, 2022

[FIXED] How to host wordpress instance as sub-directory URL when it's hosted on a separate server to the main site?

 June 25, 2022     dns, nginx, reverse-proxy, wordpress     No comments   

Issue

Given I have two separate EC2 instances:

35.0.0.1 - this one runs a web application for the main site

35.0.0.2 - this one runs the wordpress blog

How do I set up DNS and/or reverse proxies so that:

example.com - will load the web app from the first server

example.com/blog(*?) - will render pages from the WP instance on the second server

If it matters, server 1 uses nginx and server 2 uses Apache.


Solution

You could do this using reverse proxy. Since you have nginx installed at server 1 You can configure the server 2 as backend for the reverse proxy on server 1 for /blog uri.

And let your DNS point to server 1 for your domain example.com.

Config for backend and proxy setup for /blog in nginx-

upstream blog{
  server 35.0.0.2 weight=1 max_fails=2 fail_timeout=15s;
}



location /blog/ {
     proxy_pass http://blog;
}


Answered By - mdeora
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing