NGINX and configurations for e.g. a simple webserver and a SPA with prerender proxy
1.1K
The image generated by this project can be used to run an NGINX server.
The docker image contains default configurations for different setups. The default configuration that is installed is webserver.
An interesting configuration is spa-with-prerender for public websites (this requires an additional docker container for the prerendering).
Another interesting configuration is development-proxy. This proxy can be run on a local development machine to distribute (proxy) requests from a single port to frontend and backend server ports. This works great in combination with a service like NGROK.
See the examples folder for more details about how to use the default configurations.
Below an example of using the image in a docker-compose file.
In the /examples folder, you'll find more docker-files for the different setups.
version: "3.9"
services:
website:
image: hkdigital/nginx # docker-hub
# image: hkdigital-nginx # local
restart: always # "no"|always|on-failure|unless-stopped
ports:
# Let docker choose port numbers on the host
# - "80"
# host-port -> container port
- "1080:80"
volumes:
- ./volumes:/mnt # contains: webroot, config, certificates, log, media
Using the container script
docker-compose exec website /srv/check-nginx-config-and-reload.sh
This can be done manually too
docker-compose exec website nginx -t -c /@config/nginx.conf
docker-compose exec website nginx -s reload
If you just want to use the image to create a container, there is no need to build the image locally. You can use the image from docker-hub.
Building the image locally is usually done for development of the image itself.
Clone the latest commit from github into a local working directory.
git clone --depth 1 \
[email protected]:hkdigital/docker-images--nginx.git \
hkdigital-nginx
./build-latest-image.sh
docker image ls
# Shows hkdigital-nginx
Content type
Image
Digest
sha256:2fcc84674…
Size
77.7 MB
Last updated
over 3 years ago
docker pull hkdigital/nginx