0

I'm running into an issue where certain URLs passed to my Elastic Beanstalk Environment are containing slashes inside the URL's parameters e.g.:

https://example.com/param1=this/that/param2=....

These URL's are valid in the context that my application can process the slashes correctly in local testing. In production on EB, the Apache server EB uses as default decodes the slashes, causing 404's to be returned to the user. I am not very up to date on my Apache knowledge. What is the best and most efficient way to set the argument: AllowEncodedSlashes NoDecode in my Apache configurations dynamically on envrionment launch?

Obviously, ssh-ing into my instances to make the change is far from ideal and will not last past a reload. Is it possible to set it using my applications .ebextensions in some way?

EDIT:

To give some more details, I am using a load-balanced EB environment that uses HTTPS and is running a Django application (with mod_wsgi)

This is my wsgi.conf file taken from one of my instances:

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

Is this the file I have to edit? Wouldn't the EB enviornemnt overwrite my changes on an environment reboot?

GreenGodot
  • 6,030
  • 10
  • 37
  • 66
  • Possible duplicate of [Configure apache on elastic beanstalk](http://stackoverflow.com/questions/21878024/configure-apache-on-elastic-beanstalk) – Mark B Aug 07 '16 at 15:53

1 Answers1

0

Check below sample configuration for Apache to take care of the Encoded slashes. Remember this is just a sample. You have to manipulate your Apache code by taking reference of below code, as you have not pasted your apache host file it in your question.

<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>
Piyush Patil
  • 14,512
  • 6
  • 35
  • 54