Skip to content

Commit

Permalink
Lighttpd: Add socket support and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jan 20, 2025
1 parent 8821d83 commit d99c462
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ ENV MS_DEBUGLEVEL=0 \
LIGHTTPD_PORT=8080 \
LIGHTTPD_FASTCGI_HOST=spawn-fcgi \
LIGHTTPD_FASTCGI_PORT=3000 \
LIGHTTPD_FASTCGI_SOCKET= \
LIGHTTPD_ACCESSLOG_FORMAT="%h %V %u %t \"%r\" %>s %b"

CMD ["/usr/local/bin/start-server"]
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Only tags for minor releases exist, not tag for bug fixes.
If the container is run as root, apache listens on port `80`. If it is run as
another user, it listens on port `8080`.

## Tunings
## Apache Tunings

You can use the following environment variables (when starting the container)
to tune it:
Expand All @@ -29,6 +29,27 @@ to tune it:
- `APACHE_LIMIT_REQUEST_LINE`: The maximum size of the HTTP request line in
bytes (defaults to `8190`)

## Lighttpd

You can also use lighttpd as the web server.

The main benefit of that is to have only one running process per container, that's useful especially on Kubernetes.

For that you need tow containers, one for the MapServer and `spawn-fcgi`, and one for `lighttpd`.

The environment variable needed by mapserver should be on the `spawn-fcgi` container.

The MapServer logs will be available on the 'lighttpd' container.

Used environment variables:

- `LIGHTTPD_CONF`: The lighttpd configuration file (defaults to `/etc/lighttpd/lighttpd.conf`)
- `LIGHTTPD_PORT`: The port lighttpd will listen on (defaults to `8080`)
- `LIGHTTPD_FASTCGI_HOST`: The host of the FastCGI server (`spawn-fcgi`, defaults to `spawn-fcgi`)
- `LIGHTTPD_FASTCGI_PORT`: The port of the FastCGI server (`spawn-fcgi`, defaults to `3000`)
- `LIGHTTPD_FASTCGI_SOCKET`: The socket of the FastCGI server (defaults to `''`)
- `LIGHTTPD_ACCESSLOG_FORMAT`: The format of the access log (defaults to `"%h %V %u %t \"%r\" %>s %b"`)

## Running multiple Mapfiles

This section is for if you would like to use more than one Mapfile, or use a Mapfile
Expand Down
25 changes: 25 additions & 0 deletions runtime/etc/lighttpd/gen-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

if [[ "${LIGHTTPD_FASTCGI_SOCKET}" == "" ]]; then
echo '
fastcgi.server = ( "" =>
(
(
"host" => env.LIGHTTPD_FASTCGI_HOST,
"port" => env.LIGHTTPD_FASTCGI_PORT,
"check-local" => "disable",
),
)
)
'
else
echo 'fastcgi.server = ( "" =>
(
(
"socket" => env.LIGHTTPD_FASTCGI_SOCKET,
"check-local" => "disable",
),
)
)
'
fi
10 changes: 1 addition & 9 deletions runtime/etc/lighttpd/lighttpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,4 @@ server.errorlog = "/dev/fd/2"
accesslog.format = env.LIGHTTPD_ACCESSLOG_FORMAT
accesslog.filename = "/dev/fd/2"

fastcgi.server = ( "" =>
(
(
"host" => env.LIGHTTPD_FASTCGI_HOST,
"port" => env.LIGHTTPD_FASTCGI_PORT,
"check-local" => "disable",
),
)
)
include_shell "bash ./gen-server"
7 changes: 6 additions & 1 deletion runtime/usr/local/bin/start-server
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ if [[ "${SERVER}" == spawn-fcgi ]]; then
echo "Starting with spawn-fcgi"
# Save the environment to be able to restore it in the FCGI daemon (used in /usr/local/bin/mapserv_wrapper)
${GET_ENV} | sed -e 's/.\+/export "\0"/' > /tmp/init_env
/usr/bin/spawn-fcgi -p "${LIGHTTPD_FASTCGI_PORT}" -n -- /usr/local/bin/mapserv_wrapper
if [[ "${LIGHTTPD_FASTCGI_SOCKET}" == "" ]]; then
exec /usr/bin/spawn-fcgi -p "${LIGHTTPD_FASTCGI_PORT}" -n -- /usr/local/bin/mapserv_wrapper
else
exec /usr/bin/spawn-fcgi -s "${LIGHTTPD_FASTCGI_SOCKET}" -n -- /usr/local/bin/mapserv_wrapper
fi
else
if [[ "${SERVER}" == lighttpd ]]; then
echo "Starting lighttpd"
lighttpd -t -f "${LIGHTTPD_CONF}"
exec lighttpd -D -f "${LIGHTTPD_CONF}"
else
echo "Starting with apache2"
Expand Down

0 comments on commit d99c462

Please sign in to comment.