我想要实现的是将所有流量从http重定向到https。 基本上我有一个平衡的实例,http和https都工作。 (https工作正常,证书已经设置完毕),我在.war应用程序中创建了一个目录.ebextensions,里面有一个配置文件,如下所示。
files:
/etc/httpd/conf.d/vhosts.conf:
content: |
<VirtualHost *:80>
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^/(.*)$ https://www.mydomain.com/$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
检查日志我看到脚本正在执行,并且应用了更改,但我没有看到服务正在重新启动。这可能是我的问题的原因吗?或者我的脚本文件中是否有其他错误?
非常感谢你的帮助。
答案 0 :(得分:1)
我能够使其配置文件elasticbeanstalk.conf,添加此配置。
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^/(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]