AWS Elasticbeanstalk上的ALLOW_ENCODED_SLASH

ilo*_*una 5 tomcat amazon-web-services amazon-elastic-beanstalk

如何在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
Run Code Online (Sandbox Code Playgroud)

但是它似乎没有作用,也没有出现在这些目录中:

ls -la /tmp/deployment/application/ROOT/
ls -la /var/lib/tomcat7/webapps/ROOT/ 
Run Code Online (Sandbox Code Playgroud)

ilo*_*una 1

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>
Run Code Online (Sandbox Code Playgroud)

此 URL 对于配置 EBS 及其 apache http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html很有帮助