Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@orangain
Copy link
Contributor

@orangain orangain commented Feb 1, 2018

In HTTPSRedirect and similar middlewares, determining if redirection is needed using c.IsTLS() causes redirect loop when an application is running behind a TLS termination proxy, e.g. AWS ELB.

This is because c.IsTLS() always returns false behind a TLS termination proxy even when a client connects with TLS.

[Client] ---https--> [TLS termination proxy] ---http--> [Echo application using HTTPSRedirect]

Instead, I believe, redirection should be determined by c.Scheme() != "https". This works well even behind a TLS termination proxy thanks to a X-Forwarded-Proto header the proxy sets.

In HTTPSRedirect and similar middlewares, determining if redirection is
needed using `c.IsTLS()` causes redirect loop when an application is running
behind a TLS termination proxy, e.g. AWS ELB.

Instead, I believe, redirection should be determined by
`c.Scheme() != "https"`. This works well even behind a TLS termination proxy.
@codecov
Copy link

codecov bot commented Feb 1, 2018

Codecov Report

Merging #1058 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1058      +/-   ##
==========================================
+ Coverage   78.87%   78.92%   +0.05%     
==========================================
  Files          27       27              
  Lines        1879     1879              
==========================================
+ Hits         1482     1483       +1     
+ Misses        283      282       -1     
  Partials      114      114
Impacted Files Coverage Δ
middleware/redirect.go 88.23% <100%> (+1.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec048ea...23ca707. Read the comment docs.

@vishr
Copy link
Member

vishr commented Feb 1, 2018

@orangain If we move https://github.com/labstack/echo/blob/master/context.go#L233 to the bottom it should work?

@orangain
Copy link
Contributor Author

orangain commented Feb 2, 2018

@vishr I don't think a position of the if statement affects behavior of redirection. Could you please explain what you concern?

@vishr
Copy link
Member

vishr commented Feb 2, 2018

@orangain You are right!

@vishr vishr merged commit ef82f3e into labstack:master Feb 2, 2018
@vishr
Copy link
Member

vishr commented Feb 2, 2018

@orangain thanks for your contribution.

@vishr vishr self-requested a review February 2, 2018 15:31
@vishr vishr added the bug label Feb 2, 2018
@djensen47
Copy link

When will this be released? It's been almost 30 days since this was merged.

Great project! Thanks for all the hard work!

vishr pushed a commit that referenced this pull request Mar 12, 2018
Enhancements:
    Implemented Response#After()
    Dynamically add/remove proxy targets
    Rewrite rules for proxy middleware
    Add ability to extract key from a form field
    Implemented rewrite middleware
    Adds a separate flag for the 'http/https server started on' message (#1043)
    Applied a little DRY to the redirect middleware (#1053) and tests (#1055)
    Simplify dep fetching (#1062)
    Add custom time stamp format #1046 (#1066)
    Update property name & default value & comment about custom logger
    Add X-Requested-With header constant
    Return error of context.File in c.contentDisposition
    Updated deps
    Updated README.md

Fixes:

    Fixed Response#Before()
    Fixed #990
    Fix href url from armor to echo (#1051)
    Fixed #1054
    Fixed #1052, dropped param alias feature
    Avoid redirect loop in HTTPSRedirect middleware (#1058)
    Fix deferring body close in middleware/compress test (#1063)
    Cleanup code (#1061)
    FIX - We must close gzip.Reader, only if no error (#1069)
    Fix formatting (#1071)
    Can be a fix for auto TLS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.