nginx-static¶
nginx serving a static site or a single-page-app build, built locally from the
Dockerfile in this folder.
Ports¶
| Service | Host port | Container | Env var |
|---|---|---|---|
| nginx | 8090 |
80 | NGINX_PORT |
Serving your own site¶
By default the stack serves a placeholder page from a named volume seeded out
of the image. Point NGINX_SITE at a folder on your machine to serve that
instead:
Compose treats any value starting with / or . as a bind mount and anything
else as a named volume, so this one variable switches between the two with no
edit to compose.yaml.
SPA routing¶
nginx.conf uses try_files $uri /index.html, so unknown paths return your
index.html rather than a 404. React Router, Vue Router and friends work
without extra configuration. Static assets (css, js, images, fonts) are
served with a six-month cache header and no access logging.
Gotchas¶
- The old
nginxServer/run_server.shrannethmindulsara/nginx-server:v1from Docker Hub — a personal image nobody else could pull or rebuild — while ignoring the perfectly goodDockerfilesitting next to it. This stack builds locally, so what runs is what is in the repo. - Editing files in a bind-mounted folder shows up immediately; no restart is
needed. Changing
NGINX_SITEitself does need a restart, because it changes the mount. - The six-month asset cache is aggressive for local development. If you are
iterating on CSS and see stale files, hard-reload, or drop the
expiresblock fromnginx.conf. - This stack takes 8090, not 80, so it can run next to everything else. The
nginx-proxy-managerstack is the one that wants port 80.