我遇到的问题是传递给我的Elastic Beanstalk环境的某些URL在URL的参数中包含斜杠,例如:
https://example.com/param1=this/that/param2= ....
这些URL在我的应用程序可以在本地测试中正确处理斜杠的上下文中有效。在EB的生产中,Apache服务器EB使用默认值来解码斜杠,从而将404返回给用户。我对Apache的知识并不是最新的。设置参数的最佳和最有效的方法是什么:在我的Apache配置中动态地在环境启动时设置AllowEncodedSlashes NoDecode
?
显然,进入我的实例进行更改远非理想,并且不会超过重新加载。是否可以使用我的应用程序.ebextensions以某种方式设置它?
修改
为了提供更多细节,我使用的是负载均衡的EB环境,它使用HTTPS并运行Django应用程序(使用mod_wsgi)
这是我从我的一个实例中获取的wsgi.conf文件:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/python/run/baselinenv
WSGISocketPrefix run/wsgi
WSGIRestrictEmbedded On
<VirtualHost *:80>
Alias /static/ /opt/python/current/app/static/
<Directory /opt/python/current/app/static/>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / /opt/python/current/app/test_app/wsgi.py
AllowEncodedSlashes NoDecode
<Directory /opt/python/current/app/>
Require all granted
</Directory>
WSGIDaemonProcess wsgi processes=1 threads=15 display-name=%{GROUP} \
python-path=/opt/python/current/app:/opt/python/run/venv/lib64/python3.4/site-packages:/opt/python/run/venv/lib/python3.4/site-packages user=wsgi group=wsgi \
home=/opt/python/current/app
WSGIProcessGroup wsgi
</VirtualHost>
LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
这是我要编辑的文件吗?在环境重启时,EB enviornemnt不会覆盖我的更改吗?
答案 0 :(得分:0)
检查以下Apache的示例配置,以处理编码的斜杠。请记住,这只是一个示例。你必须通过参考下面的代码来操纵你的Apache代码,因为你没有在你的问题中粘贴你的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>