如何在AWS上配置ElasticBeanstalk以在URL中允许编码斜杠?(使用- Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH = true)
我已经在源包的顶级目录(http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize- containers.html)中创建了一个名为.ebextensions的目录,并带有文件tomcat.config。内容:
commands: allow-encoded-slash: command: export CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true" cwd: /home/ec2-user
但是它似乎没有作用,也没有出现在这些目录中:
ls -la /tmp/deployment/application/ROOT/ ls -la /var/lib/tomcat7/webapps/ROOT/
ElasticBeanstalk在Tomcat的前面有一个Apache(我猜为负载均衡器),因此这是第一个接收请求的人,必须在此指出不得对斜杠进行解码。
为了得到这个,我们使用了这个虚拟主机:
<VirtualHost *:80> <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://localhost:8080/ retry=0 ProxyPassReverse / http://localhost:8080/ ProxyPreserveHost on AllowEncodedSlashes NoDecode LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" ErrorLog /var/log/httpd/elasticbeanstalk-error_log TransferLog /var/log/httpd/elasticbeanstalk-access_log </VirtualHost>
此URL有助于配置EBS和他的Apache http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize- containers.html