提供非子域路由 [英] Serve non-subdomain routes
问题描述
我想使用Wordpress来托管公司的博客。主要网站是一个ASP应用程序。它们托管在不同的EC2实例上。
I want to use Wordpress to host company's blog. Main website is an ASP app. They are hosted on different EC2 instances.
博客应具有非子域名URL: example.com/blog
,不是 blog.example.com
。
Blog should have non-subdomain URL: example.com/blog
, not blog.example.com
.
如何做到这一点?像Cloudflare这样的负载均衡工具可以帮助吗?
How can this be done? Can load-balancing tool like Cloudflare help with that?
我尝试使用Route53进行某种屏蔽。还尝试在IIS中与主站点并排托管博客。
I tried doing some kind of masking using Route53. Also experimented with hosting the blog in IIS side-by-side with main site.
推荐答案
你可以把 nginx 两者上游,并将其用作反向代理,它们都匹配目标网址。
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.
示例nginx config可能如下所示:
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;
}
}
其中10.0.0.5是你的IIS服务器运行你的ASP应用程序和10.0.0.6是运行你的Wordpress服务器的任何盒子。
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.
或者你可能想看看亚马逊的API网关服务,它允许您将流量定向到您选择的端点,这些端点可能是您在AWS内的应用程序,服务器在AWS之外的某个地方,一个Lambda函数或几乎任何与HTTP对话的东西。
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.
这篇关于提供非子域路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!