Slim Nginx Containers

This Slim Starter Kit will show you how to build a Hello World Nginx website and use the Slim platform to secure it for production.
sk-g sk-g

Hello nginx and static website developers!

Optimize and harden your containerized applications the easy way — with Slim.AI.

This Starter Kit will help you proactively remove vulnerabilities from your Nginx-style websites.

Simply replace the static website code here with your own, run it through Slim.AI's automated container optimization process, and you'll remove up vulnerabilities while also making it up to 11.83X smaller.

No more chasing down hard to patch vulns that your application isn't even using, and you can use any base image you want — even nginx:latest.

Optimization Results

Result of optimized Nginx image

Slimming this nginx container results in 0- to 1-percent reduction in overall vulnerabilities.

Vulnerability difference by severity

Result of vulnerability reduction in Nginx image

Note: Vulnerability scanners do not always accurately reflect changes in containers. Please verify your results.

Get Started

To start a nginx application application, you'll need the following libraries installed locally, or running in a dev environment link GitPod, Docker Environments, or Code Spaces.

nginx:latest

Sample Application

Our sample application is a simple static page serve that merely returns "Hello World" html document.

While this app is simple, it's a great starting point for more complex development.

Project structure

├── config
│   └── nginx.config
├── content
│   └── index.html
├── Dockerfile
├── README.md

Code sample

    server {
        listen 80;
        server_name frontend.com;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
    }

Replace this placholder code with your own application code, and install any necessary dependencies, to create your own slimmable container.

Sample Dockerfile

Our Dockerfile builds off of the nginx:latest image and starts at 142MB.

FROM nginx:latest AS build-env
RUN rm /etc/nginx/conf.d/default.conf
COPY config/nginx.config /etc/nginx/conf.d/default.conf
COPY content /usr/share/nginx/html
EXPOSE 80

The slimming process reduces the size by 11.83X to just 12MB.

Try it yourself for free on Slim.AI