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

Brotli support for nginx alpine image #371

Closed
pumano opened this issue Oct 10, 2019 · 34 comments
Closed

Brotli support for nginx alpine image #371

pumano opened this issue Oct 10, 2019 · 34 comments

Comments

@pumano
Copy link

pumano commented Oct 10, 2019

Would be good to have official nginx alpine docker image with brotli support with fall back to gzip.

Previously I found #210 issue with closed #216 PR. That PR closed due to issue where google/ngx_brotli want to drop support in 2017, but today looks like google/ngx_brotli now live! Previous fork eustas/ngx_brotli merged back to original repo.

Today all major browsers support brotli and that algorithm very efficient.
Would be good to have brotli + nginx alpine docker image

@thresheek
Copy link
Collaborator

The point about not shipping third-party modules still stands though.

@ai
Copy link

ai commented Oct 21, 2019

@thresheek do we have right now any reason not to add Brotli support to nginx official modules? If there is some legal reason, could we make the exception of using a third-party module here? If there are no good reasons, how we can help in adding Brotli support to nginx?

Brotli looks like a great feature for performance, but right now there is no good Docker image with nginx and Brotli.

@thresheek
Copy link
Collaborator

The only way to add brotli to this image is to make it a part of an official nginx distribution. I see no way we can support that otherwise.

@ai
Copy link

ai commented Oct 28, 2019

@thresheek of course. I think that nginx should support Brotli by default.

What we can do to add official Brotli support? I saw batch in nginx tracker. Maybe there is a way to vote or pay to promote some feature?

@thresheek
Copy link
Collaborator

I would say sending a patch to the development mailing list would at least make sure developers could comment on it; however I see it was submitted in early 2017 with no real reply, which is frustrating.

@thresheek
Copy link
Collaborator

A viable option would be also to implement a "development image" as discussed in #239 - it wouldnt have the effect of an image that will have all the modules built-in, but would it make easier for everyone to do their own images/build the modules they need.

@pumano
Copy link
Author

pumano commented Oct 28, 2019

@thresheek in 2017 nginx devs not accept it due to same reason, because google/ngx_brotli stop their development.

@ai
Copy link

ai commented Oct 28, 2019

because google/ngx_brotli stop their development.

Now it is not a problem, since Google continue development

@pumano
Copy link
Author

pumano commented Oct 28, 2019

We need to find some idea how to create official nginx image with brotli support.

It's looks like few additional strings in dockerfile, can provide huge positive impact on community.

Also de-facto best in class nginx web server just in win-win situation if support will be provided.

@polarathene
Copy link

polarathene commented Nov 22, 2019

You can add brotli support with your own alpine image easily enough afaik. Drawback is that you don't build from source, using the version of Alpines nginx package(current alpine:3.10 provides nginx 1.16.x).

I have not tried it yet, but they have quite a few modules are available as separate packages, you just install them with the nginx package and should have support. I've done similar with PHP.

I'm not entirely sure how that works if you're meant to compile them in like I've seen official nginx and PHP images do(building from source instead). But presumably if someone submitted a nginx-mod-brotli package and that got accepted, we'd have an easy way to use brotli module. AFAIK, right now we have to maintain a fork of this repos dockerfile?

Looks like they're included as dynamically linked modules to make them optional. Is that something that could be done here too?

@eyalzek
Copy link

eyalzek commented Nov 22, 2019

A nice solution would be to create an official ONBUILD image that would allow developers to specify any additional modules which are not "officially" supported by the team, this way the responsibility of maintaining these modules wouldn't fall on the team itself, while developers would have a fairly straightforward way to build additional modules on top of the upstream image. Though I'm not really sure how simple it is to implement such an image.

@mahnunchik
Copy link

Any news?

@thresheek
Copy link
Collaborator

Nobody volunteered a solution so far.

As per ONBUILD, using those is discouraged: docker-library/official-images#2076

@tracker1
Copy link

Another possible solution, would be to add a brotli_static similar to gzip_static, so at least pre-compressed files could be served.

@Herz3h
Copy link

Herz3h commented Aug 20, 2020

What are the alternatives to have brotli if it won't be included in the base image ?

@gldraphael
Copy link

gldraphael commented Aug 20, 2020 via email

@Macil
Copy link

Macil commented Aug 20, 2020

@Herz3h The docker image fholzer/nginx-brotli has nginx with brotli support.

@tracker1
Copy link

@Macil @Herz3h I've been using xddxdd/nginx myself... But had to make a couple config mods for my own needs. As I'm precompressing the files I need compressed so don't need dynamic compression at all.

@SymbioticKilla
Copy link

SymbioticKilla commented Nov 5, 2020

Still not on roadmap? brotli is already standard for web(text) compression...

@Korijn
Copy link

Korijn commented Nov 25, 2020

Sorry for the mean words, I removed them.

Edit: I found a way to minimally extend the official image with ngx_brotli support, see here: https://github.com/Korijn/docker-nginx-brotli

@tsuna
Copy link

tsuna commented Dec 15, 2020

Would be nice to get Brotli support upstream.

@igor-adtrac
Copy link

This is a must have feature.

@ajslater
Copy link

I think there's a drop-in nginx brotli module coming to alpine soon.
https://pkgs.alpinelinux.org/package/edge/main/x86/nginx-mod-http-brotli
Its been available since nginx-1.18.0-r5, so it may arrive with alpine v3.13

@thresheek
Copy link
Collaborator

Hi. I've added a way to make it easier to add modules on top of the official image, please check https://github.com/nginxinc/docker-nginx/tree/master/modules for more information.

@georg-jung
Copy link

Thanks @thresheek for creating that Dockerfile!

I created a GitHub Actions workflow that automatically checks for updates to the official nginx:mainline image daily and uses your Dockerfile to create a version including ngx_brotli if updates are available.

I make these fully automatically built images available at georgjung/nginx-brotli, if that might help anyone.

@wokalek
Copy link

wokalek commented Jul 27, 2023

@georg-jung
Copy link

@wokalek Thanks for creating this, it's always better to have multiple options to choose from.

I created https://hub.docker.com/r/georgjung/nginx-brotli because I disliked most of the existing nginx-brotli images for becoming stale because they are manually maintained. For something as critical as a webserver it felt wrong to me that security patches could reach my servers weeks or months later if the maintainer (or: "some random dude on the internet") lost interest/is on holiday/... At the same time I fully understand and feel that keeping a close eye for regular maintenance tasks that aren't even about someone's own code (but nginx's) isn't the most fun thing to do as a freetime OSS contributor.

Nevertheless, while I wouldn't want to push anyone to use my image rather than yours, I wondered if there is any advantage in using your (manually created if I get it right?) image rather than the nginx-brotli:alpine variant of my automatically updated images?

@wokalek
Copy link

wokalek commented Jul 27, 2023

@georg-jung

Hey! Thanks for commenting on my work!

I came across your image on the Docker Hub and I remember that I tried to find the repository, but for some reason I didn’t find it with my eyes on Github (but now I took a closer look and got acquainted with it).

My image is positioned as a lightweight alternative to the original nginx image, but with brotli support.

I do not really like to enter into discussions "whose approach is better", but I will say a few words.

  1. If you are really interested, then you can compare the sizes of the resulting images. georgjung/nginx-brotli:1.25.1-alpine is 16.39 MB in size (gzip compressed). wokalek/nginx-brotli:1.25.1 is 9.36 MB, almost half that size. In this regard, your images do not differ from the official ones, just + brotli.

  2. I tried to thoroughly study the build process of the actual, latest version of nginx and did not use any extra configuration settings (unnecessary - too, which turned out to be a lot in other images). I don't think previous versions of nginx are really of interest to anyone using the server... Maybe I'm wrong, but I will support only versions from 1.25.1.

  3. You're right, automatic build is really cool. And I saw this not only in your repository, and I myself want to automate it when my hands reach it (:
    But when that will be, I can't say right now.
    Yes, at the moment I build images manually.

  4. I actively monitor OpenSSL and its HTTP3/QUIC support and plan to update my image (http3 branch) with the versions of these libraries as well (+ brotli). At the moment, this is a highly unstable technology that can only be used by enthusiasts, but I hope that it will soon become stable and the new standard.

  5. And perhaps the most important plus. In my repository there is a completely understandable and clean dockerfile, on the basis of which you can build your own nginx build with your modules.
    It is more suitable for familiarizing the process of building nginx than most other dockerfiles that I found on the Internet.

@wokalek
Copy link

wokalek commented Jul 27, 2023

Brotli is included in NGINX Plus, so it's never will be included in standard nginx (who knows...)

@thresheek
Copy link
Collaborator

thresheek commented Jul 27, 2023

@wokalek Brotli support in NGINX Plus is exactly the same what we ship via https://github.com/nginxinc/docker-nginx/tree/master/modules and pkg-oss. In fact, NGINX Plus build system uses pkg-oss for those modules.

@wokalek
Copy link

wokalek commented Jul 27, 2023

@wokalek Brotli support in NGINX Plus is exactly the same what we ship via https://github.com/nginxinc/docker-nginx/tree/master/modules and pkg-oss. In fact, NGINX Plus build system uses pkg-oss for those modules.

I mean it won't be included by default in a standard nginx build. You must specify it for the build yourself, or use NGINX Plus, if I understand everything correctly.

@thresheek
Copy link
Collaborator

Indeed. At least for now, there are no plans to include Brotli support in main nginx codebase.

@ciprianmacovei
Copy link

thank u @georg-jung for the nginx-brotli img :D works perfectly

@opablo
Copy link

opablo commented Apr 30, 2024

This is what I had to do to add brotli and other modules to my official nginx docker image...

nginxcache/Dockerfile

FROM nginx:1.26.0-alpine

# deleting the limited (no extra modules) nginx 1.26.x installation
RUN apk del -r nginx

# installing the alpine os native nginx 1.24.0 with the extra modules we need
RUN apk add --no-cache \
  nginx \
  nginx-mod-http-vts \
  nginx-mod-http-brotli \
  nginx-mod-http-cache-purge \
  nginx-mod-http-headers-more

docker-compose.yml

  nginxcache:
    build:
      context: nginxcache
    container_name: nginxcache-dev
    restart: unless-stopped
    volumes:
      - nginxcache:/var/cache/nginx
      - ./nginxcache/nginx.conf:/etc/nginx/nginx.conf
      - ./nginxcache/localhost.crt:/etc/ssl/localhost.crt
      - ./nginxcache/localhost.key:/etc/ssl/localhost.key

you can trigger the creation of such local image using:
docker-compose build
before running
docker-compose up

it's wrong... it's not really what I want... it's actually using the nginx compiled by alpine and not the nginx compiled by nginx team... but this hack is what I'm using while I wait for the nginx team to provide a better solution to have an official image with official brotli support

again.. it's not what I really want... but sharing what I am currently doing in case it's of use to others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests