I want to use Wordpress to host company's blog. Main website is an ASP app. They are hosted on different EC2 instances.
Blog should have non-subdomain URL: example.com/blog
, not blog.example.com
.
How can this be done? Can load-balancing tool like Cloudflare help with that?
I tried doing some kind of masking using Route53. Also experimented with hosting the blog in IIS side-by-side with main site.
You could put nginx upstream of both of them and use it as a reverse proxy to both of them matching the URL that is being targeted.
A sample nginx config might look something like this:
server {
server_name example.com;
location / {
proxy_pass http://10.0.0.5;
}
location /blog/ {
proxy_pass http://10.0.0.6;
}
}
Where 10.0.0.5 is your IIS server running your ASP application and 10.0.0.6 is whatever box is running your Wordpress server.
Alternatively you might want to take a look at Amazon's API Gateway service which allows you to direct traffic to your chosen end points which could be your application inside AWS, a server somewhere outside of AWS, a Lambda function or pretty much anything that "talks" HTTP.
CloudFlare isn't a "load-balancing tool" it's a CDN built on nginx and a DNS service. I'm not aware of any load-balancing feature that CloudFlare provides. You could probably setup a page rule in CloudFlare to accomplish what you want. The problem there is going to be the requirement that you use CloudFlare as your DNS server, which may not be ideal for you.
You could do what ydaetskcoR suggests and put your own nginx server in front of both web servers. That would be my recommendation.
Route53 is a DNS system, and only deals with domain names. It will not help you solve this situation.
来源:https://stackoverflow.com/questions/34345576/serve-non-subdomain-routes