使用Elastic Beanstalk ELB重定向到Https

编程入门 行业动态 更新时间:2024-10-27 12:40:13
本文介绍了使用Elastic Beanstalk ELB重定向到Https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要完成的工作是将所有流量从http重定向到https. 基本上,我有一个平衡的实例,可以同时使用http和https. (https正常工作,证书已设置),我在.war应用程序中创建了一个目录.ebextensions,其中包含一个配置文件,如下所示.

What I want to accomplish is to redirect all traffic from http to https. Basically I have a balanced instance, with both http and https working. (The https is working fine, the certificate has been setted up), and I have created a directory .ebextensions in my .war application with a config file inside as following.

files: /etc/httpd/conf.d/vhosts.conf: content: | <VirtualHost *:80> RewriteCond %{HTTP:X-Forwarded-Proto} !=https RewriteRule ^/(.*)$ www.mydomain/$1 [R=301,L] </VirtualHost> group: root mode: "000644" owner: root services: sysvinit: httpd: enabled: true ensureRunning: true files: - /etc/httpd/conf.d/vhosts.conf

日志...

2014-05-16 01:27:48,253 [DEBUG] /etc/httpd/conf.d/vhosts.conf already exists 2014-05-16 01:27:48,254 [DEBUG] Moving /etc/httpd/conf.d/vhosts.conf.bak to /etc/httpd/conf.d/vhosts.conf.bak2 2014-05-16 01:27:48,254 [DEBUG] Moving /etc/httpd/conf.d/vhosts.conf to /etc/httpd/conf.d/vhosts.conf.bak 2014-05-16 01:27:48,254 [DEBUG] Writing content to /etc/httpd/conf.d/vhosts.conf 2014-05-16 01:27:48,254 [DEBUG] Setting mode for /etc/httpd/conf.d/vhosts.conf to 000644 2014-05-16 01:27:48,254 [DEBUG] Setting owner 0 and group 0 for /etc/httpd/conf.d/vhosts.conf 2014-05-16 01:27:48,255 [DEBUG] Moving /etc/httpd/conf.d/vhosts.conf.bak2 to /etc/httpd/conf.d/vhosts.conf.bak 2014-05-16 01:27:48,255 [DEBUG] No commands specified 2014-05-16 01:27:48,255 [DEBUG] Using service modifier: /sbin/chkconfig 2014-05-16 01:27:48,255 [DEBUG] Setting service httpd to enabled 2014-05-16 01:27:48,372 [INFO] enabled service httpd 2014-05-16 01:27:48,372 [DEBUG] Using service runner: /sbin/service 2014-05-16 01:27:48,469 [DEBUG] No need to modify running state of service httpd 2014-05-16 01:27:48,481 [INFO] Running configSet Hook-PreAppDeploy

检查日志,我看到脚本正在执行,并且已应用更改,但是我没有看到服务正在重新启动.那可能是我问题的原因吗?还是我的脚本文件中出现另一个错误?

Checking the logs I'm seeing that the script is being executed, and the changes applied, but I'm not seeing the service being restarted. Could that be the reason on my problem? Or do I have another error in my script file?

非常感谢您的帮助.

推荐答案

我能够使其配置文件elasticbeanstalk.conf并添加此配置.

I was able to make it work configuring the file elasticbeanstalk.conf, adding this configuration.

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !=https RewriteRule ^/(.*)$ %{SERVER_NAME}%{REQUEST_URI} [L,R=301]

更多推荐

使用Elastic Beanstalk ELB重定向到Https

本文发布于:2023-11-01 19:45:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550235.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   Beanstalk   Elastic   Https   ELB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!