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

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

Open
hanscees opened this issue Mar 7, 2024 · 1 comment
Open

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

hanscees opened this issue Mar 7, 2024 · 1 comment
Labels

Comments

@hanscees
Copy link

hanscees commented Mar 7, 2024

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>
@gstrauss
Copy link

server.port = 80 # unnecessary; this is the lighttpd default
server.bind = "0.0.0.0" # unnecessary; this is the lighttpd default

unnecessary; lighttpd has default mimetype.assign for common web mime types which is larger than this list

# 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"
 )

The sample config does not use mod_access, mod_rewrite, or mod_auth. The only one used is mod_accesslog, and so this

server.modules              = (
            "mod_access",
#            "mod_status",
            "mod_accesslog",
   #     "mod_fastcgi",
            "mod_rewrite",
        "mod_auth"
)

could be replaced by
server.modules += ("mod_accesslog")

Whitespace should be consistent (and excess whitespace at end of lines removed)

Commented lines such as #server.error-handler-404 = "/e404.php" or # "mod_status", or # "mod_fastcgi", should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants