【问题标题】:Lighttpd git-http-backend setenv issueLighttpd git-http-backend setenv 问题
【发布时间】:2018-10-19 10:57:27
【问题描述】:

我在 Ubuntu 14.04 上进行了功能设置,通过 apt 安装了 Lighttpd 1.4.33,该设置传递给 git-http-backend 用于 git http pull/push。这是通过 ldap 验证的。 ldap 组查找的新要求意味着我需要更新 lighttpd 以支持它。

由于 lighttpd 在 trusty/universe 上只能升级到 1.4.33,因此旧版本已被删除,因此下载了 Lighttpd 1.4.51 的副本并从源代码编译:

./configure --with-openssl --with-openssl-libs=/usr/bin/openssl --with-ldap

在设置了几个缓存文件夹并设置了权限之后,lighttpd 启动并且似乎正在处理请求。当从客户端执行 git pull 时,日志会显示将其发送到 git-http-backend 的请求,但是在验证客户端后会在 git pull 上看到:

fatal: repository 'https://git.company.co.uk/repos/project_portal.git/' not found

git repos 所在文件夹的权限看起来是正确的,并且 lighttpd 以与工作设置中相同的用户身份运行。

我的猜测是 lighttpd.conf 中的 setenv.add-environment 配置项没有被 git-http-backend 传递/拾取,所以它不知道物理文件在哪里。

我也尝试编译不同版本的 lighttpd,但是它们都有相同的问题,可能我缺少编译选项。

来自以下 lighttpd.conf 的相关部分。

server.modules = (
    "mod_auth",
    "mod_access",
    "mod_accesslog",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    "mod_rewrite",
    "mod_webdav",
    "mod_fastcgi",
    "mod_cgi",
    "mod_setenv",
    "mod_proxy",
    "mod_authn_ldap",
    "mod_openssl"
)

server.document-root        = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80
accesslog.filename          = "/var/log/lighttpd/access.log" 

debug.log-request-handling = "enable"

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

$SERVER["socket"] == "0.0.0.0:443" {

    ssl.engine = "enable"
    ssl.pemfile = "/etc/lighttpd/ssl/git.company.co.uk.pem"
    ssl.ca-file = "/etc/lighttpd/ssl/xxxIntermediateCertificate.crt"

    $HTTP["host"] == "git.company.co.uk" {
        ssl.pemfile = "/etc/lighttpd/ssl/git.company.co.uk.pem"
        alias.url = ( "/repos" => "/usr/lib/git-core/git-http-backend" )
        $HTTP["url"] =~ "^/repos" {
            cgi.assign = ("" => "")
            setenv.add-environment = (
                "GIT_PROJECT_ROOT" => "/var/www/repositories",
                "GIT_HTTP_EXPORT_ALL" => ""
            )
            auth.require = ( "" => (
                "method" => "basic",
                "realm" => "repos",
                "require" => "valid-user"
            ))
            auth.backend = "ldap"
            auth.backend.ldap.hostname              = "172.xxx"
            auth.backend.ldap.base-dn               = "OU=ITS,xxx"
            auth.backend.ldap.filter                = "(CN=$)"
            auth.backend.ldap.bind-dn               = "CN=xxx"
            auth.backend.ldap.bind-pw               = "xxx"
            auth.backend.ldap.allow-empty-pw        = "disable"
        }
    }
}

lighttpd -V

lighttpd/1.4.51 (ssl) - a light and fast webserver

Event Handlers:

        + select (generic)
        + poll (Unix)
        + epoll (Linux)
        - /dev/poll (Solaris)
        - eventports (Solaris)
        - kqueue (FreeBSD)
        - libev (generic)

Network handler:

        + linux-sendfile
        - freebsd-sendfile
        - darwin-sendfile
        - solaris-sendfilev
        + writev
        + write
        - mmap support

Features:

        + IPv6 support
        + zlib support
        + bzip2 support
        + crypt support
        + SSL support
        + PCRE support
        - MySQL support
        - PgSQL support
        - DBI support
        - Kerberos support
        + LDAP support
        - PAM support
        - memcached support
        - FAM support
        - LUA support
        - xml support
        - SQLite support
        - GDBM support

错误日志

2018-10-22 07:21:55: (response.c.422) -- splitting Request-URI
2018-10-22 07:21:55: (response.c.423) Request-URI     :  /repos/project_portal.git/info/refs?service=git-                             upload-pack
2018-10-22 07:21:55: (response.c.424) URI-scheme      :  https
2018-10-22 07:21:55: (response.c.425) URI-authority   :  git.company.co.uk
2018-10-22 07:21:55: (response.c.426) URI-path (raw)  :  /repos/project_portal.git/info/refs
2018-10-22 07:21:55: (response.c.427) URI-path (clean):  /repos/project_portal.git/info/refs
2018-10-22 07:21:55: (response.c.428) URI-query       :  service=git-upload-pack
2018-10-22 07:21:55: (mod_access.c.156) -- mod_access_uri_handler called
2018-10-22 07:21:55: (response.c.573) -- before doc_root
2018-10-22 07:21:55: (response.c.574) Doc-Root     : /var/www
2018-10-22 07:21:55: (response.c.575) Rel-Path     : /repos/project_portal.git/info/refs
2018-10-22 07:21:55: (response.c.576) Path         :
2018-10-22 07:21:55: (response.c.628) -- after doc_root
2018-10-22 07:21:55: (response.c.629) Doc-Root     : /var/www
2018-10-22 07:21:55: (response.c.630) Rel-Path     : /repos/project_portal.git/info/refs
2018-10-22 07:21:55: (response.c.631) Path         : /var/www/repos/project_portal.git/info/refs
2018-10-22 07:21:55: (response.c.655) -- logical -> physical
2018-10-22 07:21:55: (response.c.656) Doc-Root     : /var/www
2018-10-22 07:21:55: (response.c.657) Basedir      : /usr/lib/git-core/git-http-backend
2018-10-22 07:21:55: (response.c.658) Rel-Path     : /repos/project_portal.git/info/refs
2018-10-22 07:21:55: (response.c.659) Path         : /usr/lib/git-core/git-http-backend/project_portal.gi                             t/info/refs
2018-10-22 07:21:55: (response.c.671) -- handling physical path
2018-10-22 07:21:55: (response.c.672) Path         : /usr/lib/git-core/git-http-backend/project_portal.gi                             t/info/refs
2018-10-22 07:21:55: (response.c.679) -- handling subrequest
2018-10-22 07:21:55: (response.c.680) Path         : /usr/lib/git-core/git-http-backend
2018-10-22 07:21:55: (response.c.681) URI          : /repos
2018-10-22 07:21:55: (response.c.682) Pathinfo     : /project_portal.git/info/refs
2018-10-22 07:21:55: (mod_access.c.156) -- mod_access_uri_handler called
2018-10-22 07:21:55: (mod_compress.c.854) -- handling file as static file

欢迎提出建议,谢谢。

【问题讨论】:

    标签: lighttpd git-http-backend


    【解决方案1】:

    检查 /var/log/lighttpd/error.log 中的 lighttpd 错误日志。

    检查服务器上 git-http-backend 的路径。可能是 /usr/lib/git-core/git-http-backend,也可能是 /usr/libexec/git-core/git-http-backend。

    尝试为 "GIT_HTTP_EXPORT_ALL" => "1" 设置一个值,否则 git 不会导出 repos。如果您查看 lighttpd 损坏日志(从 CGI 输出),如果已配置,或者如果您在前台 (-D) 启动 lig​​httpd 并查看来自 git-http-backend 的跟踪,您可以看到这一点。

    【讨论】:

    • 错误日志中没有明显的内容,已将问题更新为副本。仔细检查您建议的路径,它是正确的。
    • 尝试禁用 mod_compress。如果您提供的日志是完整的,那么为什么 mod_compress 处理请求?尝试(暂时)禁用其他模块以创建更简单的配置,并可能有助于缩小问题所在。
    • 禁用 mod_compress(和其他非必需的 mods)并没有改变 git pull 消息。除了丢失了一些特定于 mod 的行之外,日志也没有显示任何变化。
    • 尝试为 "GIT_HTTP_EXPORT_ALL" => "1" 设置一个值,否则 git 不会导出 repos。如果您查看 lighttpd 损坏日志(来自 CGI 的输出),如果已配置,或者如果您在前台(-D)启动 lig​​httpd 并查看来自 git-http-backend 的跟踪,您可以看到这一点。我也会将其编辑到我上面的答案中。
    • 天哪!我刚刚在 Ubuntu Impish 上将 lighttpd 升级到了 1.4.59,并在当天进行了故障排除。最终需要"GIT_HTTP_EXPORT_ALL" => "1" 来修复它。以前没必要。所以再次改变了行为,让add-environment 不添加空变量? @gstrauss?此外,它仍然不在 git 文档中 > github.com/git/git/pull/546
    猜你喜欢
    • 2023-03-30
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    • 2017-04-16
    • 2018-07-06
    • 2020-03-13
    相关资源
    最近更新 更多