I was looking trough my options for a development dev server, but nothing seemed that good. So I decided to roll my own small script to start a podman container with nginx running in it to serve the files. That way it also matches my production system somewhat, though I did enable things like filelisting, so that developement is easier, and disabled some optimizations and tweaks that I use in prod.
Implementation
I made the following small script, and stored it in /usr/local/bin/serve.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
set -e
if[ -z "$1"];thenDIR="$(pwd)"elif[[ -d "$1"]];thenDIR=$(cd"$1";pwd)elseecho"Invalid directory"exit1fiecho"Starting server on http://localhost:8080/"podman run --rm -it -p 8080:8080 \
-v "$DIR:/var/www:ro"\
-v /usr/local/etc/nginx-serve.conf:/etc/nginx/nginx.conf:ro \
-e NGINX_ENTRYPOINT_QUIET_LOGS=1\
nginx:alpine
It requires a config for nginx though from /usr/local/etc/nginx-serve.conf, which I made as follows:
events{# Dev server, assuming almost no load
worker_connections256;}http{access_logoff;error_log/dev/null;charsetUTF-8;server_tokensoff;client_body_buffer_size10m;client_header_buffer_size10k;client_max_body_size10m;large_client_header_buffers28k;sendfileon;tcp_nopushon;keepalive_timeout120;server{listen8080default_server;ssion;root/var/www;autoindexon;try_files$uri$uri.html$uri/index.html$uri/=404;}}
Now serving some directory is as simple as running serve.sh directory in my terminal to quickly start the server.