0

My setup has the current auth config. it forces authentication by any remote host. That's good. But I need to make an exception.

auth_file="/etc/lighttpd.users"
#if auth_file is not empty enable lighttpd local authentification

if grep -q ".*:.*" "$auth_file" 2>/dev/null;then
    sed -ir '/^$/d' $auth_file
    cat <<EOF
\$HTTP["remoteip"] != "127.0.0.1" {

    auth.backend = "htdigest"
    auth.backend.htdigest.userfile = "$auth_file"

    auth.require = (
        "/" => (
        "method"  => "digest",
        "realm"   => "MyRealm",
        "require" => "valid-user"
        )
    )
}
EOF
fi

I setup a second server on a different port (as seen below). I'd like to make an exception to my auth script such that users to this 2nd site do not require authentication.

$SERVER["socket"] == ":8080" {
        server.document-root = "/www2"
                }
NinjaCat
  • 576
  • 1
  • 9
  • 20

1 Answers1

1

Seems like you've already got it, just not put together. If you have config options for the other server above, you might need to put that in the else block first.

\$SERVER["socket"] == ":8080" {
    server.document-root = "/www2"
} 
else \$HTTP["remoteip"] != "127.0.0.1" {

    auth.backend = "htdigest"
    auth.backend.htdigest.userfile = "$auth_file"

    auth.require = (
        "/" => (
        "method"  => "digest",
        "realm"   => "MyRealm",
        "require" => "valid-user"
        )
    )
}
Andrew Domaszek
  • 5,103
  • 1
  • 14
  • 26