简体   繁体   中英

How to point example.com/directory to another EC2 instance with SSL?

I have all my website files - example.com - on my EC2 server (Ubuntu and Apache) with SSL on EC2 instance 1. I want example.com/blog to go to another EC2 instance - EC2 instance 2. How can I do that with SSL?

I'm using Ubuntu and Apache and Route 53. thanks!

One easy way to do this is with CloudFront, described in this answer at Server Fault , where you can use path patterns to determine which URLs will be handed off to which server.

Another is an Application Load Balancer (ELB/2.0), which allows the instance to be selected based on path rules .

Both of these solutions support free SSL certificates from Amazon Certificate Manager.

Or, you can use ProxyPass in the Apache config on the main example.com web server to relay all requests matching specific paths oer to a different instance.

You cannot accomplish this with Route 53 alone, because DNS does not work at the path level. This is not a limitation in Route 53, it's a fundamental part of how DNS works.

You quickly and easily achieve this by using nginx reverse proxy. Your ssl will still be managed and offloaded on the ELB level. That is listener 443 =>> 80

1) install nginx

yum install nginx

2) add to nginx config

upstream server1 {

        server  127.0.0.1:8080;

}

upstream server2 {

        server  server2_IP_address_here:8080;


}

server {
        listen 80;
        server_name example.com;

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

                proxy_pass http://server1;
                proxy_set_header Host $http_host;
                proxy_set_header  X-Real-IP  $remote_addr;  
      }              

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM