There are 2 EC2 instances running:
- Windows Server 2012 - ASP.NET application
- Linux - Wordpress Blog
The ASP application is on domain.com/
How can you point Wordpress to domain.com/blog/
instead of blog.domain.com
?
You can use any AWS feature.
2 Answers
Answers 1
The most cost-efficient way I see to do it is by using the resources you have already. The basic idea is to point your Route53 record to one of the EC2 instances and use "something" (I'll explain this later) to redirect the requests from this EC2 to the other. It can be either from the Windows one to the Linux one or the other way around. For example:
Let's say you point your domain (domain.com
) to the Linux EC2 instance. Let's name this one as EC2-Linux
. Install the afore mentioned "something", I'd suggest nginx
in this box. If you aren't familiar with ngnix, check out their how-to's.
Once you have nginx
up and running, create a config file with a redirect rule like (note: I haven't tested this conf file):
server { listen 80; server_name domain.com; # Redirect blog request to itself location /blog { proxy_pass http://localhost:80/$uri; proxy_set_header Host $host:$server_port; } # Redirect the rest of the traffic to the other EC2 instance location /* { proxy_pass http://<EC2-Win IP>:80/$uri; proxy_set_header Host $host:$server_port; } }
You surely need to fine tune nginx
and your applications to make it work, but I think the idea answers your question without needing to add more AWS resources to your stack.
Regards
Answers 2
You can create CloudFront distribution with /blog/ origin to the Linux server, and default to ASP.Net, which means everything other than /blog/ will go to ASP.Net.
0 comments:
Post a Comment