Docker Environments
Overview
Section titled “Overview”This page covers using LiteHTTPD with:
- ols-docker-env (docker-compose based)
- Official OLS Docker images (
litespeedtech/openlitespeed) - Custom Docker deployments
All approaches share the same base image: litespeedtech/openlitespeed. The key challenge is that the OLS binary is baked into the image and must be replaced or overlaid.
Option A: Custom Docker Image (Recommended)
Section titled “Option A: Custom Docker Image (Recommended)”Build a custom image with the patched OLS binary and LiteHTTPD module:
FROM litespeedtech/openlitespeed:1.8.5-lsphp83
# Copy patched binary and moduleCOPY openlitespeed-patched /usr/local/lsws/bin/openlitespeedCOPY litehttpd_htaccess.so /usr/local/lsws/modules/COPY litehttpd-confconv /usr/local/lsws/bin/
# Enable the module (only if httpd_config.conf is not volume-mounted)RUN if ! grep -q 'litehttpd_htaccess' /usr/local/lsws/conf/httpd_config.conf; then \ printf '\nmodule litehttpd_htaccess {\n ls_enabled 1\n}\n' \ >> /usr/local/lsws/conf/httpd_config.conf; \ fi
# Disable OLS built-in upgrade to prevent accidental binary overwriteRUN mv /usr/local/lsws/admin/misc/lsup.sh /usr/local/lsws/admin/misc/lsup.sh.disabled 2>/dev/null || trueUpdate docker-compose.yml:
services: litespeed: image: your-registry/openlitespeed-litehttpd:1.8.5 # ... rest of config unchangedOption B: Volume Mount (Quick Testing)
Section titled “Option B: Volume Mount (Quick Testing)”Mount the patched binary and module into a stock container without building a custom image:
services: litespeed: image: litespeedtech/openlitespeed:1.8.5-lsphp83 volumes: - ./lsws/conf:/usr/local/lsws/conf - ./sites:/var/www/vhosts # LiteHTTPD additions: - ./litehttpd/openlitespeed:/usr/local/lsws/bin/openlitespeed:ro - ./litehttpd/litehttpd_htaccess.so:/usr/local/lsws/modules/litehttpd_htaccess.so:roAdd the module block to your host-side ./lsws/conf/httpd_config.conf:
module litehttpd_htaccess { ls_enabled 1}Option C: Thin Mode (No Binary Replacement)
Section titled “Option C: Thin Mode (No Binary Replacement)”If you only need Thin mode features (no RewriteRule execution, no php_value), you can mount just the module .so without replacing the binary:
volumes: - ./litehttpd/litehttpd_htaccess.so:/usr/local/lsws/modules/litehttpd_htaccess.so:roDocker-Specific Considerations
Section titled “Docker-Specific Considerations”Container Restart Reverts In-Container Changes
Section titled “Container Restart Reverts In-Container Changes”Any changes made inside a running container (e.g., running lsup.sh, editing files) are lost on restart. Always use volume mounts or custom images for persistent changes.
Config Volumes Are Persistent
Section titled “Config Volumes Are Persistent”If ./lsws/conf is mounted from the host (standard in ols-docker-env), your httpd_config.conf changes persist across container restarts and image updates.
Pin the Image Tag
Section titled “Pin the Image Tag”When litespeedtech/openlitespeed releases a new image, do not blindly pull it. Pin the tag in docker-compose.yml and test before upgrading:
image: litespeedtech/openlitespeed:1.8.5-lsphp83 # pinnedDisable lsup.sh
Section titled “Disable lsup.sh”The stock image includes /usr/local/lsws/admin/misc/lsup.sh. Running it via the WebAdmin console downloads and replaces the OLS binary inside the container. In Option B (volume mount), the :ro flag prevents overwriting. In Option A, remove the script in the Dockerfile.
Disable autoLoadHtaccess
Section titled “Disable autoLoadHtaccess”If your mounted configs have OLS’s autoLoadHtaccess 1, disable it to avoid double-processing:
sed -i 's/autoLoadHtaccess.*1/autoLoadHtaccess 0/' ./lsws/conf/vhosts/*/vhost.confVerification
Section titled “Verification”# Inside the containerdocker exec -it litespeed bash
echo 'Header set X-LiteHTTPD "active"' > /var/www/vhosts/localhost/html/.htaccesscurl -sI http://localhost:8088/ | grep X-LiteHTTPD# Expected: X-LiteHTTPD: active
# Verify patches (Full mode)strings /usr/local/lsws/bin/openlitespeed | grep -q 'set_php_config_value' && echo "patch 0001 OK"strings /usr/local/lsws/bin/openlitespeed | grep -q 'parse_rewrite_rules' && echo "patch 0002 OK"strings /usr/local/lsws/bin/openlitespeed | grep -q 'readApacheConf' && echo "patch 0003 OK"