Skip to content

request.secure is set to false if X-Forwarded-For and X-Forwarded-Proto are of different length #6845

@danishin

Description

@danishin

Play Version (2.5.x / etc)

2.5

API (Scala / Java / Neither / Both)

Scala

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

MacOS 10.11.5

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

OpenJDK 1.8.x

Expected Behavior

If app is behind multiple reverse proxies, X-Forwarded-Forwill correctly be multiple values but X-Forwarded-Proto might not be (which is actually what is recommended in Django framework as it states reverse proxy to strip out all previous X-Forwarded-Proto and insert single flag.). In this case, where two are of different length and X-Forwarded-Proto is single value, it should use that value for secure flag instead of defaulting to false.

Actual Behavior

secure flag is defaulted to false.


My current setting is using heroku on top of cloudflare. Heroku seems to strip out / don't add to existing X-Forwarded-Proto, which is set by cloudflare in front. So even when we use Full SSL for cloudflare (which mandates ssl connection for both heroku - cloudflare and cloudflare - client), X-Forwarded-Proto is still set to single https value, which fails play parser for secure flag and make it defaulted to to false.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions