简体   繁体   English

如何使用SSL将example.com/directory指向另一个EC2实例?

[英]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? 我在EC2实例1上具有SSL的EC2服务器(Ubuntu和Apache)上拥有我所有的网站文件-example.com。我希望example.com/blog转到另一个EC2实例-EC2实例2。使用SSL?

I'm using Ubuntu and Apache and Route 53. thanks! 我正在使用Ubuntu和Apache和Route53。谢谢!

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. 一种简单的方法是使用CloudFront, 这在Server Fault的此答案中进行了描述,您可以在其中使用路径模式来确定将哪些URL切换到哪个服务器。

Another is an Application Load Balancer (ELB/2.0), which allows the instance to be selected based on path rules . 另一个是应用程序负载平衡器(ELB / 2.0),它允许根据路径规则选择实例。

Both of these solutions support free SSL certificates from Amazon Certificate Manager. 这两种解决方案均支持Amazon Certificate Manager提供的免费SSL证书。

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. 或者,您可以在主要example.com Web服务器上的Apache配置中使用ProxyPass ,将与特定路径匹配的所有请求中继到另一个实例。

You cannot accomplish this with Route 53 alone, because DNS does not work at the path level. 您不能仅通过Route 53来完成此操作,因为DNS在路径级别上不起作用。 This is not a limitation in Route 53, it's a fundamental part of how DNS works. 这不是Route 53的限制,它是DNS工作方式的基本组成部分。

You quickly and easily achieve this by using nginx reverse proxy. 您可以使用nginx反向代理快速轻松地实现这一目标。 Your ssl will still be managed and offloaded on the ELB level. 您的ssl仍将在ELB级别上进行管理和卸载。 That is listener 443 =>> 80 那就是监听器443 = >> 80

1) install nginx 1)安装nginx

yum install nginx

2) add to nginx config 2)添加到nginx配置

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;  
      }              

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Apache服务器中虚拟地将http://example.com指向http://ex2.com/example? - How can I virtually point http://example.com to http://ex2.com/example in apache server? 如何将 example.com 和 example.com/anything 重定向到 example.com/blog - How to redirect example.com and example.com/anything to example.com/blog .htaccess重定向到example.com,但目录重定向到example.com/example - .htaccess redirect to example.com except for directory redirect to example.com/example mod_rewrite到ssl在example.com上不起作用,但在example.com/index.html上起作用 - mod_rewrite to ssl not working for example.com but does for example.com/index.html 如何指向Amazon EC2实例的本地主机? - How to point to the Amazon EC2 instance's localhost? 如何将 AWS LightSail WordPress 实例配置为 map 为 example.com/blog - How to configure AWS LightSail WordPress instance to map as example.com/blog 如何在Apache conf的Servername设置中包含目录(example.com/dir)? - How to contain a directory (example.com/dir) in Apache conf's Servername setting? 在AWS EC2实例上启用SSL - Enabling SSL on an AWS EC2 instance 在EC2上的apache实例上启用SSL - Enabling SSL on apache instance on EC2 如何让Google将我的链接显示为example.com,而不显示为example.com/ - How do I get google to display my link as example.com NOT example.com/
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM