Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lighttpd: Add socket support and documentation #931

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 18 additions & 7 deletions runtime/etc/lighttpd/lighttpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@ server.errorlog = "/dev/fd/2"
accesslog.format = env.LIGHTTPD_ACCESSLOG_FORMAT
accesslog.filename = "/dev/fd/2"

fastcgi.server = ( "" =>
(
env.LIGHTTPD_FASTCGI_SOCKET == "" {
fastcgi.server = ( "" =>
(
"host" => env.LIGHTTPD_FASTCGI_HOST,
"port" => env.LIGHTTPD_FASTCGI_PORT,
"check-local" => "disable",
),
(
"host" => env.LIGHTTPD_FASTCGI_HOST,
"port" => env.LIGHTTPD_FASTCGI_PORT,
"check-local" => "disable",
),
)
)
)
} else {
fastcgi.server = ( "" =>
(
(
"socket" => env.LIGHTTPD_FASTCGI_SOCKET,
"check-local" => "disable",
),
)
)
}
6 changes: 5 additions & 1 deletion runtime/usr/local/bin/start-server
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ 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"
Expand Down
Loading