Git Product home page Git Product logo

docker-lighttpd's Introduction

Lighttpd

Docker Pulls Back project

Alpine linux with Lighttpd built from source.

Lighttpd (lighty) is a lightweight web-server which is designed and optimized for high performance environments. Lighttpd is open source under the revised BSD license.

To add a new configurations (more than the default configuration), add a new *.conf file to the /usr/local/lighttpd.d directory. Each file in that directory will be included into the configuration.
If you wish to replace the base configuration fully, replace the /etc/lighttpd/conf.d/lighttpd.conf file or add a new file and change the CONFIG_FILE env variable to your preferred path.

Deprecation of FPM / introduction of CGI

The -fpm tagged images are deprecated as of 2021-11-28 and will stop receiving updates.
For a replacement, see the -cgi tagged images, which will be similar but with some differences.

Tags

Tags are based on lighttpd version where latest is the latest version at build time.
Older versions are not re-built, only latest version.

Images can be found at:

  • Docker hub: jitesoft/lighttpd
  • GitLab: registry.gitlab.com/jitesoft/dockerfiles/lighttpd
  • GitHub: ghcr.io/jitesoft/lighttpd
  • Quay quay.io/jitesoft/httpd

Dockerfiles can be found at GitLab and GitHub.

The image

This image contains lighttpd built from source, it runs on the alpine linux distro, making it a small image keeping the disk, cpu and ram at a minimum!

www-data user

Prior to 2021 07 23, the image used the user lighttpd (1000/1000) to run the image.
This have been changed to use the default www-data group and a www-data user with id 82 to comply with standard www-data user in alpine images.

Containers created runs as root (easily changed in production with the appropriate flags), while the lighttpd process runs as the www-data user (82) by default.

Environment variables

The following environment variables are used and exposed in the dockerfile:

PORT=80
SERVER_NAME=localhost
SERVER_ROOT=/var/www/html
CONFIG_FILE=/etc/lighttpd/lighttpd.conf
SKIP_HEALTHCHECK=false
MAX_FDS=1024

The default configuration file is located at /etc/lighttpd/lighttpd.conf but your own can be included in whatever way you wish. If you are not replacing the default file you can use the CONFIG_FILE variable to point to your own file and ignore the default. PORT 80 is exposed and used by default, if changed, the default configuration will use the port defined in the env variable but you will have to expose it by yourself. SERVER_NAME defaults to localhost. SERVER_ROOT defaults to /var/www/html.

The SKIP_HEALTHCHECK flag will, if set to "true" mark the container as healthy as long as it is running, while if left default or set to "false" will run a query on the 127.0.0.1:${PORT} endpoint every minute.
It's exposed as an environment variable due to the fact that a 404 will be reported as an error and exit the health check with a none-0 exit code.

The MAX_FDS variable sets the maximum file descriptors used by lighttpd and could be tweaked if needed.

CGI tag

The cgi tagged image have mod_fastcgi enabled with env variables set to enable connection to a separate cgi host. The lighttpd container will await the cgi host before starting by checking the host with nc (netcat, busybox version).

CGI_HOST="fpm"
CGI_PORT="9000"
CHECK_LOCAL="enable"
CGI_FILE_EXT=".php"

If you do not want to share data between your containers, set the CHECK_LOCAL to "disable" to ignore local files in the lighttpd container.

The default configuration (which resides in /etc/lighttpd/conf.d) contains the following configuration:

server.modules += ("mod_fastcgi")
fastcgi.server += ( env.CGI_FILE_EXT =>
        ((
                "host" => env.CGI_HOST,
                "port" => env.CGI_PORT,
                "broken-scriptfilename" => "enable",
                "docroot" => env.SERVER_ROOT,
                "check-local" => env.CHECK_LOCAL

        ))
)

Once the cgi container have connected, it will create an empty file in /tmp/ready which can be used as a startup indicator if needed.

Image labels

This image follows the Jitesoft image label specification 1.0.0.

Licenses

This repository is released under the MIT license.
You can find the Lighttpd license here.

Sponsors

Jitesoft images are built via GitLab CI on runners hosted by the following wonderful organisations:

Oregon State University - Open Source Lab

The companies above are not affiliated with Jitesoft or any Jitesoft Projects directly.


Sponsoring is vital for the further development and maintaining of open source.
Questions and sponsoring queries can be made by email.
If you wish to sponsor our projects, reach out to the email above or visit any of the following sites:

Open Collective
GitHub Sponsors
Patreon

docker-lighttpd's People

Contributors

johannestegner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker-lighttpd's Issues

[Q] - how i can restart the server through dockerfile?

Hi, i cant figure out how i can reload, stop or restart the lighttpd, im shure im missing something, maybe the way i want to do things.

this is my workflow on my dockerfile:

FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package.json ./
RUN yarn install
COPY . ./
RUN yarn build

################################################################
ENV PORT=80
ENV SERVER_NAME=localhost
ENV SERVER_ROOT=/var/www/html
ENV CONFIG_FILE=/etc/lighttpd/lighttpd2.conf
ENV SKIP_HEALTHCHECK=false
ENV MAX_FDS=1024
# ##############################################
FROM jitesoft/lighttpd as deploy-stage

LABEL maintainer="[email protected]"

COPY --from=build-stage /app/dist /var/www/html/
WORKDIR /etc/lighttpd/
COPY lighttpd2.conf .
EXPOSE 80

After copy the file lighttpd2.conf i want to reload the server with this file as the config.
i dont know if im doing everything wrong, but any clue would be apreciate.
btw, this is my lighttpd2.conf

server.modules += ("mod_access", "mod_accesslog", "mod_rewrite", "mod_auth")
server.document-root = env.SERVER_ROOT
server.port = env.PORT
server.name = env.SERVER_NAME
server.username  = "www-data"
server.groupname = "www-data"
server.indexfiles = ("index.php", "index.html", "index.htm")
server.max-fds = env.MAX_FDS
static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi")
url.access-deny = ("~", ".inc")
server.follow-symlink = "enable"
dir-listing.activate = "disable"

url.rewrite-if-not-file = ("/.*" => "/index.html")

basically i want to get rid of 404 errors on my vuejs3/vite website and i found this is a way.

[Q] - here is a good working config for lightttpd with vhost

Hi,

thanks for the docker image of this webserver.

it took me some time to find a decent config to use and a decent docker-compose file that works.
So I will share them here to save others some time

If there are mistakes in them please do point them out.
I am using a totally static website.

docker-compose.yml

version: "2.4"

services:
  lighttpd:
    image: jitesoft/lighttpd
    restart: always
    volumes:
      - ./www:/var/www
      - ./etc:/etc/lighttpd
      - ./log:/var/log/lighttpd
    ports:
      - "80:80"
    tty: true

and config file

server.port = 80                                                                                                   
server.username = "www-data"                                                                                       
server.groupname = "www-data"                                                                                      
server.bind                = "0.0.0.0"                                                                             
server.tag ="lighttpd"                                                                                             

$HTTP["host"] =~ "(^|\.)zanscees\.com$" {                                                                          
server.document-root = "/var/www/hansceescom/html"                                                                 
server.errorlog = "/var/log/lighttpd/hansceescom/error.log"                                                        
accesslog.filename = "/var/log/lighttpd/hansceescom/access.log"                                                    
#server.error-handler-404 = "/e404.php"                                                                            
}                                                                                                                  
                                                                                                                   
                                                                                                                   
server.document-root = "/var/www/root/html"                                                                        
server.errorlog            = "/var/log/lighttpd/root/error.log"                                                    
accesslog.filename         = "/var/log/lighttpd/root/access.log"                                                   
                                                                                                                   
server.modules              = (                                                                                    
            "mod_access",                                                                                          
#            "mod_status",                                                                                         
            "mod_accesslog",                                                                                       
   #     "mod_fastcgi",                                                                                            
            "mod_rewrite",                                                                                         
        "mod_auth"                                                                                                 
)                                                                                                                  
                                                                                                                   
# mimetype mapping                                                                                                 
mimetype.assign             = (                                                                                    
  ".pdf"          =>      "application/pdf",                                                                       
  ".wav"          =>      "audio/x-wav",                                                                           
  ".gif"          =>      "image/gif",                                                                             
  ".jpg"          =>      "image/jpeg",                                                                            
  ".jpeg"         =>      "image/jpeg",                                                                            
  ".png"          =>      "image/png",                                                                             
  ".css"          =>      "text/css",                                                                              
  ".html"         =>      "text/html",                                                                             
  ".htm"          =>      "text/html",                                                                             
  ".bz2"          =>      "application/x-bzip",                                                                    
  ".tbz"          =>      "application/x-bzip-compressed-tar",                                                     
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"                                                      
 )                                                                                                                 
index-file.names = ( "index.html" ) 



and to make all files using the yml file above

mkdir -p www/hansceescom/html
mkdir -p www/root/html
mkdir -p log/hansceescom/
mkdir -p log/root/
mkdir -p root/
mkdir -p etc/

touch log/hansceescom/error.log
touch log/hansceescom/access.log
touch log/root/error.log
touch log/root/access.log
vi etc/lighttpd.conf 
vi www/hansceescom/html/index.html
vi www/root/html/index.html


chmod 666 log/hansceescom/error.log
chmod 666 log/hansceescom/access.log
chmod 666 log/root/error.log
chmod 666 log/root/access.log



##index.html 
<html>
Hi this is root
</html>

How to make SPA compatible?

Although i am running Lighttpd on my dietpi server i am not that experienced with it. And even after Googling i did not found out how i can basically have something like https://github.com/SocialEngine/docker-nginx-spa just with your lovely alpine+lighttpd combo. I am refering to the fact that everything it routed to the root path so that i can just deploy my svelte SPA app with a index.html and still access mydomain.com/sub/route which should serve the index.html and not tryint to access a /sub/route folder.

I am grateful for any help here, as i think this package is better suited for small containers instead of the bigger nginx combo.

[Q] - How to pass the env variable to config file?

Hi, I really like your container and have been using it for a while.

I am wondering, how did you manage to pass the environment variables to the config files by just calling the variables name, for example: env.SERVER_ROOT, env.PORT, ... ? I have seen people did this through the entrypoint script, but it's not in your case.

Thank you.

[BUG] - Cannot log to stderr

Context

if you add

server.errorlog = "/dev/stderr"
accesslog.filename = "/dev/stdout"

to lighttpd.conf, container will not work

Awaiting connection to CGI host
CGI host found, starting lighttpd!
2022-12-10 17:09:30: (configfile.c.1720) opening errorlog '/dev/stderr' failed: Permission denied
2022-12-10 17:09:30: (server.c.1584) Opening errorlog failed. Going down.

Description
I see it's a common issue, somebody solved in this way:
thecodingmachine/docker-images-php@941219f

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.