6

I have a small Flask application that I want to run on AWS Elastic Beanstalk.

The application deploys and runs fine but I've noticed that a custom HTTP Header (HTTP_CUSTOM_TOKEN) is not present in request.headers.

I'm assuming I'm missing something from the Apache configuration but am not very familiar with that environment.

0

3 Answers 3

10

What you need is something similar to what @Fartash suggested, just slightly different.

Add .ebextensions/python.config :

container_commands:
  03wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'

as explained at Using the AWS Elastic Beanstalk Python Platform

Sign up to request clarification or add additional context in comments.

3 Comments

Hey, what does "../wsgi.conf" refer to? an existing file?
The "../wsgi.conf" file will be created if it doesn't exist. See askubuntu.com/a/401926
../wsgi.conf must refer to a path that is somehow read by Apache HTTPD. Is this documented somewhere?
5

Remove underscores from the header variables, example:-

header_var_val = "some value"
replace it with -- headervarval = "some value"

Comments

4

You need to enable the WSGIPassAuthorization. If you do not specifically enable auth forwarding, apache will consume the required headers and your app won't receive it.

Add this to your *.config file in .ebextensions folder.

commands: WSGIPassAuthorization: command: sed -i.bak '/WSGIScriptAlias/ a WSGIPassAuthorization On' config.py cwd: /opt/elasticbeanstalk/hooks

1 Comment

what does config.py refer to?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.