A Lighttpd web server based on Alpine Linux
93
This is a Lighttpd web server based on Alpine Linux.
The versions are as follows: Alpine Linux and Lighttpd.
Alpine Linux: 3.19.0
Lighttpd: 1.4.73 (ssl)
And please refer to below.
The size of the image: 13.7MB
Supported Protocols: HTTPS
Redirect HTTP to HTTPS
You can use it by following the steps below.
Pull the image.
docker pull pikamonvvs/lighttpd-alpine:1.0
The configuration involves utilizing SSL certificates and keys from your host machine.
Therefore, it is necessary to obtain SSL certificates on your host machine using Let's Encrypt and install them in the /etc/letsencrypt directory.
Please consult the provided documentation below for detailed instructions on obtaining and installing the certificates.
Ubuntu 22.04 - Let's Encrypt Standalone
The server operates on ports 80 and 443, thus, it is essential to open these ports.
Additionally, you need to mount directories for SSL certificates.
docker run -d --name [container_name] -p 80:80 -p 443:443 \
-v /etc/letsencrypt/archive/[domain_name]:/etc/letsencrypt/archive/[domain_name] \
-v /etc/letsencrypt/live/[domain_name]:/etc/letsencrypt/live/[domain_name] \
-e DOMAIN_NAME=[domain_name] \
pikamonvvs/lighttpd-alpine:1.0
When you start the container, it automatically launches a web server.
You can check if it is running by using the following commands.
curl -k https://localhost
Enjoy using it!
I created this image using various files provided below.
# Use a lightweight Alpine Linux image
FROM alpine:latest
# Expose port 80, 443 (HTTP, HTTPS)
EXPOSE 80
EXPOSE 443
# Install lighttpd
RUN apk update && \
apk --no-cache add lighttpd
# Copy the custom lighttpd configuration file inside the container, overriding the default
COPY lighttpd.conf /etc/lighttpd/lighttpd.conf
# Copy the SSL configuration files for HTTPS
COPY ssl.conf /etc/lighttpd/ssl.conf
COPY ssl-config.conf /etc/lighttpd/ssl-config.conf
# Create necessary directories
RUN mkdir -p /var/cache/lighttpd/uploads
# Copy an HTML file to the web root directory inside the container
COPY index.html /var/www/localhost/htdocs/
# Create a script to configure SSL and start lighttpd
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Use the script as ENTRYPOINT
ENTRYPOINT ["/entrypoint.sh"]
server.modules += ( "mod_accesslog" )
server.document-root = "/var/www/localhost/htdocs"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "lighttpd"
index-file.names += ( "index.html" )
accesslog.filename = "/var/log/lighttpd/access.log"
include "ssl.conf"
server.modules += ( "mod_openssl" )
$SERVER["socket"] == ":443" {
# HTTPS configuration
include "ssl-config.conf"
server.document-root = "/var/www/localhost/htdocs"
server.errorlog = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"
}
# Redirect HTTP to HTTPS
server.modules += ( "mod_redirect" )
$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "([^:/]+)" {
url.redirect = ( "^/(.*)" => "https://%1/$1" )
}
}
# SSL settings
# SSL settings
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/DOMAIN_NAME/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/DOMAIN_NAME/privkey.pem"
#!/bin/sh
sed -i -e "s/DOMAIN_NAME/${DOMAIN_NAME}/g" /etc/lighttpd/ssl-config.conf
exec lighttpd -D -f /etc/lighttpd/lighttpd.conf
<!DOCTYPE html>
<html>
<head>
<title>Alpine + lighttpd</title>
</head>
<body>
<h1>Hello, this is a simple Alpine + lighttpd Docker container!</h1>
</body>
</html>
docker build -t pikamonvvs/lighttpd-alpine:1.0 .
Content type
Image
Digest
sha256:8be2d21ba…
Size
7.1 MB
Last updated
over 2 years ago
docker pull pikamonvvs/lighttpd-alpine:1.0