Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out pass-through compression for nginx #5989

Closed
Tratcher opened this issue Oct 7, 2016 · 11 comments
Closed

Figure out pass-through compression for nginx #5989

Tratcher opened this issue Oct 7, 2016 · 11 comments
Labels
affected-few This issue impacts only small number of customers area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware feature-response-compression help wanted Up for grabs. We would accept a PR to help resolve this issue severity-nice-to-have This label is used by an internal tool task
Milestone

Comments

@Tratcher
Copy link
Member

Tratcher commented Oct 7, 2016

When a request is proxied behind nginx the Accept-Encoding header is removed. This prevents the back-end from being able to compress the response.

Nginx supports compression on the front end, and compression between the back end and the front end, but it does not seem to allow the back-end compression to pass-through. See the integration tests in the ServerTests repo.

@Tratcher
Copy link
Member Author

Tratcher commented Oct 7, 2016

@guardrex
Copy link
Contributor

@Tratcher I'm doing the 2.0 topic updates now. There's no movement on this issue, correct? The current text states ...

Middlware issue when behind an Nginx reverse-proxy

When a request is proxied by Nginx, the Accept-Encoding header is removed. This prevents the middleware from compressing the response. For more information, see [NGINX: Compression and Decompression](https://www.nginx.com/resources/admin-guide/compression-and-decompression/). This issue is tracked by [Figure out pass-through compression for nginx (BasicMiddleware #123)](https://github.com/aspnet/BasicMiddleware/issues/123).

Leave it as it is?

@Tratcher
Copy link
Member Author

@guardrex correct, no progress.

@olsh
Copy link
Contributor

olsh commented Oct 16, 2017

Is there any workaround for the issue?

@Tratcher
Copy link
Member Author

You'll have to take that up with nginx.

@aspnet-hello aspnet-hello transferred this issue from aspnet/BasicMiddleware Dec 19, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 19, 2018
@TwentyFourMinutes
Copy link

Any updates so far?

@tebeco
Copy link
Contributor

tebeco commented Mar 4, 2020

@Tratcher sorry to ping you about this, i was looking at the docs here :
https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-3.1#working-with-iis-dynamic-compression

That pointed to this issue. As we nginx in k8s for the ingress part, i supposed we will be impacted by this as well ?

i'm not sure how to understand this :

You'll have to take that up with nginx.

Does it means AspNetCore cannot do this for you and you need to configure your own NGINX to be sure it properly forward the headers .... ?
If so, should this issue be closed ?

As it's both open and backlog, i do wonder if something is gonna be changed to aspnetcore to make it changed, and what ?
(also i would ask about the potential release where it would land ^^)

@Tratcher
Copy link
Member Author

Tratcher commented Mar 4, 2020

We have not found a way to make this work properly with nginx. If someone figures it out then we'll make any necessary changes to the middleware.

@martint17r
Copy link

Just a drive by comment - I don't know jack about dot.net...
At least for nginx>=1.14 adding

proxy_http_version 1.1;
gzip on;

to the frontend nginx enables the pass-through compression.

@Tratcher Tratcher added affected-few This issue impacts only small number of customers severity-nice-to-have This label is used by an internal tool labels Nov 9, 2020 — with ASP.NET Core Issue Ranking
@V4A001
Copy link

V4A001 commented Dec 3, 2020

Idea to post on Nginx github?

@andtii
Copy link

andtii commented Jan 25, 2021

I just did a test on latest nginx on kubernetes installed by helm and it looks like nginx is forwarding the Accept-Encoding headers to the upstream server. Below image show the headers in the request from .net core webapp in a pod behind nginx
image

Im going to implement max brotli compression on publish for our js/css resources and then serve them directly from memory

@davidfowl davidfowl added the help wanted Up for grabs. We would accept a PR to help resolve this issue label Mar 28, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Oct 28, 2022
@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affected-few This issue impacts only small number of customers area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware feature-response-compression help wanted Up for grabs. We would accept a PR to help resolve this issue severity-nice-to-have This label is used by an internal tool task
Projects
None yet
Development

No branches or pull requests