Slim Nginx, multi-arch alpine Docker image with substitution filter module.
The final result is a clean image completely based on the official nginx:alpine
.
Does not contain any compile time junk, the only additions are:
- Dynamic module inserted at
/usr/lib/nginx/modules/ngx_http_subs_filter_module.so
; - Importing of the module in
/etc/nginx/nginx.conf
withload_module
.
Available on DockerHub and on GitHub container registry:
docker pull tofran/nginx-with-substitutions-filter
# or
docker pull ghcr.io/tofran/nginx-with-substitutions-filter
This repo could also be helpful as a recipe for building images with any other dynamic modules, or even as way to extract compiled binaries from them.
Create the following example configuration ./sample.conf
:
server {
listen 80;
location / {
subs_filter_types text/html text/css text/xml application/javascript;
subs_filter "nginx" "replaced";
root /usr/share/nginx/html;
}
}
Now run the image:
docker run -p 8080:80 -v ./sample.conf:/etc/nginx/conf.d/default.conf tofran/nginx-with-substitutions-filter
Visit http://localhost:8080
:
There you go, you now have a nginx running with on-the-fly string replacement. Happy replacing!
MIT