Project

General

Profile

Enable logs in lighttpd

Added by mukeshsale almost 4 years ago

I am not able to generate the logs.My lighttpd config is as below:

server.modules              = ("mod_fastcgi", "mod_setenv")
#server.upload-dirs = ( "/usr/local/lmedia/lost+found", "/tmp" )
accesslog.filename = "/var/log/http.log" 
#accesslog.format = "%h %U %t "%{Referer}i" "%{User-Agent}i"" 

include "mod_websocket.conf" 

server.document-root        = "/usr/local/www" 
server.pid-file = "/var/run/lighttpd.pid" 

# files to check for if .../ is requested
index-file.names            = ( "home.html","index.php", "index.html",
                                "index.htm", "default.htm", "index.html.gz","viewer.html")

server.error-handler-404 = "/index.html" 

debug.log-request-handling = "enable" 
debug.log-state-handling = "enable" 
debug.log-request-header="enable" 
debug.log-response-header="enable" 

server.max-read-idle = 120
server.max-keep-alive-idle = 120
fastcgi.debug = 1

fastcgi.server += ("/api" =>
((
  "bin-path"    => "/usr/local/bin/spx_restservice",
  "max-procs"   => 1,
  "socket"    => "/tmp/spx_restservice.socket",
  "check-local" => "disable",
  "allow-x-send-file" => "enable" 
)))

#include_shell "[ -f /conf/lighttpd_ext.conf ] && cat /conf/lighttpd_ext.conf || echo -n " 
include "lighttpd_ext.conf" 

#use always https feature based support
include "mod_always_https.conf" 
# mimetype mapping
mimetype.assign             = (
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".xml"          =>      "text/xml",
  ".elg"          =>      "application/x-ibmclog",
  ".jnlp"         =>      "application/x-java-jnlp-file",
  ".gz"       =>    "application/x-gzip",
  ".tar.gz"   =>    "application/x-gzip-compressed-tar" 
 )

#enable ipv6 support
server.use-ipv6 = "enable" 
server.socket = "[::]:80" 

## bind to port (default: 80)
server.port = 80

## SSL Engine
$SERVER["socket"] == ":443" {
  ssl.engine = "enable" 
  server.use-ipv6 = "enable" 
  ssl.cipher-list = "TLSv1+HIGH !SSLv2 !RC4 !aNULL !eNULL !3DES @STRENGTH" 
}

$HTTP["url"] =~ "\.js$|\.html$|\.css$|\.png$|\.woff$|\.jpg$|^/$" {
setenv.add-response-header += ( "Content-Encoding" => "gzip","X-Frame-Options" => "SAMEORIGIN")
}
##set cache control to no only for url with /api/
$HTTP["url"] =~ "^/api" {
setenv.add-response-header += ( "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" )
}

#include "redfish_lighttpd.conf" 


Let me know wht can i do to have logs enabled.


Replies (5)

RE: Enable logs in lighttpd - Added by gstrauss almost 4 years ago

Please look at the error message when you start up lighttpd.

You can test the config with:

lighttpd -tt -f /etc/lighttpd/lighttpd.conf

Modules must be listed in server.modules before they can be used.

RE: Enable logs in lighttpd - Added by mukeshsale almost 4 years ago

Thanks

Ran with above option:

/conf/user_home/admin $ /usr/local/sbin/lighttpd -tt -f /conf/lighttpd.conf
WEB is enabled and port numbers are NON-SSL:0x50 SSL:0x1bb
2020-05-19 16:18:23: (mod_fastcgi.c.1501) --- fastcgi spawning local \n\tproc: /usr/local/bin/spx_restservice \n\tport: 0 \n\tsocket /tmp/spx_restservice.socket \n\tmax-procs: 1
2020-05-19 16:18:23: (mod_fastcgi.c.1525) --- fastcgi spawning \n\tport: 0 \n\tsocket /tmp/spx_restservice.socket \n\tcurrent: 0 / 1
2020-05-19 16:18:23: (mod_fastcgi.c.1501) --- fastcgi spawning local \n\tproc: /usr/local/bin/spx_restservice_ext \n\tport: 0 \n\tsocket /tmp/spx_restservice_ext.socket \n\tmax-procs: 1
2020-05-19 16:18:23: (mod_fastcgi.c.1525) --- fastcgi spawning \n\tport: 0 \n\tsocket /tmp/spx_restservice_ext.socket \n\tcurrent: 0 / 1
2020-05-19 16:18:23: (mod_fastcgi.c.1501) --- fastcgi spawning local \n\tproc: /usr/local/bin/redfish.fcgi \n\tport: 1026 \n\tsocket  \n\tmax-procs: 1
2020-05-19 16:18:23: (mod_fastcgi.c.1525) --- fastcgi spawning \n\tport: 1026 \n\tsocket  \n\tcurrent: 0 / 1
2020-05-19 16:18:23: (server.c.1430) WARNING: unknown config-key: accesslog.filename (ignored)
2020-05-19 16:18:23: (server.c.1430) WARNING: unknown config-key: server.socket (ignored)

RE: Enable logs in lighttpd - Added by mukeshsale almost 4 years ago

PLease find the internal format printing of lighttpd.conf

/usr/local/sbin/lighttpd -p -f /conf/lighttpd.conf
Before InitWebServiceConfig
start
End
WEB is enabled and port numbers are NON-SSL:0x50 SSL:0x1bb
config {
    var.PID                    = 24805
    var.CWD                    = "/conf/user_home/admin" 
    accesslog.filename         = "/var/log/http.log" 
    server.port                = 80
    websocket.timeout          = 0
    websocket.server           = (
        "^\/kvm"       => (
            "host"     => "127.0.0.1",
            "port"     => 7578,
            "proto"    => "tcp",
            "type"     => "binary",
            "subproto" => "binary",
            # 5
        ),
        "^\/cd-server" => (
            "host"     => "127.0.0.1",
            "port"     => 5120,
            "proto"    => "tcp",
            "type"     => "binary",
            "subproto" => "binary",
            # 5
        ),
        # 2
    )
    server.document-root       = "/usr/local/www" 
    server.pid-file            = "/var/run/lighttpd.pid" 
    index-file.names           = (
        "home.html",
        "index.php",
        "index.html",
        "index.htm",
        "default.htm",
        "index.html.gz",
        "viewer.html",
        # 7
    )
    server.error-handler-404   = "/index.html" 
    debug.log-request-handling = "enable" 
    debug.log-state-handling   = "enable" 
    debug.log-request-header   = "enable" 
    debug.log-response-header  = "enable" 
    server.max-read-idle       = 120
    server.max-keep-alive-idle = 120
    fastcgi.debug              = 1
    server.modules             = ("mod_fastcgi", "mod_setenv", "mod_websocket", "mod_redirect")
    mimetype.assign            = (
        ".gif"    => "image/gif",
        ".jpg"    => "image/jpeg",
        ".jpeg"   => "image/jpeg",
        ".png"    => "image/png",
        ".css"    => "text/css",
        # 5
        ".html"   => "text/html",
        ".htm"    => "text/html",
        ".js"     => "text/javascript",
        ".text"   => "text/plain",
        ".txt"    => "text/plain",
        # 10
        ".xml"    => "text/xml",
        ".elg"    => "application/x-ibmclog",
        ".jnlp"   => "application/x-java-jnlp-file",
        ".gz"     => "application/x-gzip",
        ".tar.gz" => "application/x-gzip-compressed-tar",
        # 15
    )
    server.use-ipv6            = "enable" 
    server.socket              = "[::]:80" 
    fastcgi.server             = (
        "/api"     => (
            (
                "bin-path"          => "/usr/local/bin/spx_restservice",
                "max-procs"         => 1,
                "socket"            => "/tmp/spx_restservice.socket",
                "check-local"       => "disable",
                "allow-x-send-file" => "enable",
                # 5
            ),
        ),
        "/ext"     => (
            (
                "bin-path"          => "/usr/local/bin/spx_restservice_ext",
                "max-procs"         => 1,
                "socket"            => "/tmp/spx_restservice_ext.socket",
                "check-local"       => "disable",
                "allow-x-send-file" => "enable",
                # 5
            ),
        ),
        "/redfish" => (
            (
                "bin-path"    => "/usr/local/bin/redfish.fcgi",
                "host"        => "127.0.0.1",
                "port"        => 1026,
                "check-local" => "disable",
                "max-procs"   => 1,
                # 5
            ),
        ),
        # 3
    )

    $HTTP["scheme"] == "http" {
        # block 1

        $HTTP["host"] =~ "^(.*):" {
            # block 2
            url.redirect = (
                "^(.*)$" => "https://%0$0",
            )

        } # end of $HTTP["host"] =~ "^(.*):" 
    } # end of $HTTP["scheme"] == "http" 

    $SERVER["socket"] == ":80" {
        # block 3

        $HTTP["host"] =~ ".*" {
            # block 4
            url.redirect = (
                ".*" => "https://%0$0",
            )

        } # end of $HTTP["host"] =~ ".*" 
    } # end of $SERVER["socket"] == ":80" 

    $SERVER["socket"] == ":443" {
        # block 5
        ssl.engine      = "enable" 
        server.use-ipv6 = "enable" 
        ssl.cipher-list = "TLSv1+HIGH !SSLv2 !RC4 !aNULL !eNULL !3DES @STRENGTH" 

    } # end of $SERVER["socket"] == ":443" 

    $HTTP["url"] =~ "\.js$|\.html$|\.css$|\.png$|\.woff$|\.jpg$|^/$" {
        # block 6
        setenv.add-response-header = (
            "Content-Encoding" => "gzip",
            "X-Frame-Options"  => "SAMEORIGIN",
            # 2
        )

    } # end of $HTTP["url"] =~ "\.js$|\.html$|\.css$|\.png$|\.woff$|\.jpg$|^/$" 

    $HTTP["url"] =~ "^/api" {
        # block 7
        setenv.add-response-header = (
            "Cache-Control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
        )

    } # end of $HTTP["url"] =~ "^/api" 
}

RE: Enable logs in lighttpd - Added by gstrauss almost 4 years ago

Please look at the warning and error messages when you start up lighttpd.

Read them to yourself and think about them.
Read them out loud.

Fix the warnings and errors.

RE: Enable logs in lighttpd - Added by mukeshsale almost 4 years ago

Thanks.I am able to resolve the issues and now able to work on webserver...Appriciate showing me the debug.

Only thing,i would like to confirm if i need to add below file.I see that file is not present in my /conf folder..If i generate that file with required data,it would work properly.

#use always https feature based support
include "mod_always_https.conf"

    (1-5/5)