This is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving static content efficiently.
The recommended method for using the Alwatr Nginx is to place it behind a Kubernetes ingress or a simple edge reverse-proxy like Traefik.
In this setup, there's no need to configure edge features such as SSL, Domain, etc. in the Alwatr Nginx.
FROM ghcr.io/alwatr/nginx:2ARG NODE_VERSION=lts
ARG ALWATR_NGINX_VERSION=2
FROM docker.io/library/node:${NODE_VERSION} as builder
WORKDIR /app
COPY package.json *.lock ./
RUN if [ -f *.lock ]; then \
yarn install --frozen-lockfile --non-interactive --production false; \
else \
yarn install --non-interactive --production false; \
fi;
COPY . .
RUN yarn build
# ---
FROM ghcr.io/alwatr/nginx-pwa:${ALWATR_NGINX_VERSION} as nginx
# Config nginx
ENV NGINX_ACCESS_LOG="/var/log/nginx/access.log json"
# Copy builded files from last stage
COPY --from=builder /app/dist/ ./
RUN pwd; ls -lAhF;Set NGINX_LOWERCASE_URI=on to serve a request path with uppercase letters from its lowercase file (e.g. /Assets/Logo.PNG serves /assets/logo.png) instead of returning 404. A file that really has uppercase letters is still served as is. There is no redirect; $request_uri and the query string stay untouched.
ENV NGINX_LOWERCASE_URI=onA tiny native module (ngx_http_lowercase_uri_module, built in the base nginx image) adds the $lowercase_uri variable, and the root location uses it only as a try_files fallback:
try_files $uri $uri/ $lowercase_uri $lowercase_uri/ =404;So the lowercase path is built and checked only when the original path is missing. When disabled (default), the module is not loaded at all. You can use $lowercase_uri in your own try_files too.
PCRE Just-In-Time compilation is enabled by default (pcre_jit on;) in the main configuration context. Regular expressions defined at configuration parsing time (such as location ~ ..., rewrite, and map directives used for MIME-type mapping and WebP detection) are JIT-compiled into native machine code at startup, significantly reducing CPU overhead and speeding up regex matching during request handling.
The following companies, organizations, and individuals support Nginx ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.
Contributions are welcome! Please read our contribution guidelines before submitting a pull request.
This project is licensed under the MPL-2.0 License.