A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label lighttpd. Show all posts
Showing posts with label lighttpd. Show all posts

Quickly use a webserver to serve a local directory

Steps:
  • sudo yum install lighttpd
  • # Create a file containing:

    server.document-root = "/path/to/your/directory/here/" 
    
    server.port = 3000
    
    mimetype.assign = (
      ".html" => "text/html", 
      ".txt" => "text/plain",
      ".jpg" => "image/jpeg",
      ".png" => "image/png" 
    )
    
    
  • lighttpd -t -f lighttpd.conf # check config
  • lighttpd -D -f lighttpd.conf # run webserver

(source)

Use lighttpd as a proxy-pass server

$HTTP["host"] =~ "made.up.hostname" { # hostname you want to create
    $SERVER["socket"] == ":1234" { # port you want to create

        server.errorlog      = "/var/logs/madeup/lighttpd-error.log"
        accesslog.filename   = "/var/logs/madeup/lighttpd-access.log"

        proxy.server = ( "" =>
                           ( ( 
                               "host" => "123.456.789.012", # where you want to proxy to
                               "port" => 5678, # port you want to proxy to
                             ) ) 
                         )   
    }   
}

# Now go to http://made.up.hostname:1234 and you will get directed through to http://123.456.789.012:5678