【发布时间】:2017-02-27 01:09:21
【问题描述】:
在过去的几天里,我一直在尝试强制我的应用程序将对我的域的非 https 调用转发到 https 调用。
我有一个配置了 64 位 Amazon Linux 2016.03 v2.2.0 运行 Tomcat 8 Java 8 的 Web 服务器弹性 beanstalk。我在我的应用程序中创建了一个名为 .ebextensions 的文件夹,其中包含一个名为 ssl_rewrite.config 的文件。该文件包含以下内容:
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
它曾经包含这个 taken from this example,但我收到了 if 语句的错误:
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
无论如何,当我尝试部署我的应用时,它失败了,我收到了这个错误:
Application update failed at 2016-10-17T01:33:00Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03_configure_proxy.sh failed.
Executing: /opt/elasticbeanstalk/bin/log-conf -n httpd -l'/var/log/httpd/*'
Executing: /usr/sbin/apachectl -t -f /var/elasticbeanstalk/staging/httpd/conf/httpd.conf
Syntax error on line 1 of /etc/httpd/conf.d/ssl_rewrite.conf:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Failed to execute '/usr/sbin/apachectl -t -f /var/elasticbeanstalk/staging/httpd/conf/httpd.conf'
Failed to execute '/usr/sbin/apachectl -t -f /var/elasticbeanstalk/staging/httpd/conf/httpd.conf'.
我已经进入 httpd.conf 文件并添加了这一行:
LoadModule rewrite_module modules/mod_rewrite.so
关于我做错了什么的任何提示或想法?谢谢!
【问题讨论】:
标签: amazon-web-services ssl mod-rewrite amazon-elastic-beanstalk amazon-elb