本文介绍了AWS Elasticbeanstalk上的ALLOW_ENCODED_SLASH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该如何在AWS上配置ElasticBeanstalk以允许URL中使用编码的斜杠?(使用-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH = true)

How should I configure my ElasticBeanstalk on AWS to allow encoded slashes in URLs ?(Using -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true)

我在源包的顶级目录中创建了一个名为.ebextensions的目录,其中包含文件tomcat.config( http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html ),内容如下:

I've created a directory called .ebextensions with a file tomcat.config in top-level directory of my source bundle (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html) with the content:

commands:
  allow-encoded-slash:
    command: export CATALINA_OPTS="$CATALINA_OPTS -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
    cwd: /home/ec2-user

但是它似乎没有效果,它没有出现在这些目录中:

But it seems it has no effect, it doesn't appear in these dirs:

ls -la /tmp/deployment/application/ROOT/
ls -la /var/lib/tomcat7/webapps/ROOT/ 

推荐答案

ElasticBeanstalk在Tomcat的前面有一个apache(我想是负载均衡器),因此这是第一个接收请求的人,必须在哪里表示不得对斜杠进行解码.

An ElasticBeanstalk has an apache (I guess for the Load Balancer) on front of Tomcat, so this is the first one who receives a request, and is where must be indicated that slashes must be not decoded.

为了得到这个,我们使用了这个虚拟主机:

In order to get this, we have used this virtualhost:

<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

This URL is helpful to configure an EBS and his apache http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html

这篇关于AWS Elasticbeanstalk上的ALLOW_ENCODED_SLASH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 18:54