推送时使用nginx和git-http-backend 403

问题描述

我试图设置一个git服务器,其前端为 for lab_reference in lab_references: print(lab_reference.name,lab_reference.max) provsvar_new.style.set_properties(**{'background-color': 'white','color': 'black','border-color': 'black','border-width': '1px','border-style': 'solid'}) \ .applymap(lambda x: get_style(x,lab_reference),subset=[lab_reference.name]) provsvar_new.to_excel(output_file,engine='openpyxl',sheet_name='summary',index=False) ,后端为<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> <script src="./scripts/jquery.mask.js"></script> <script> // https://learn.jquery.com/using-jquery-core/document-ready/ $(document).ready( function () { $("#ssnId").mask("999-99-9999"); } ); </script> </head> <body> SSN:<br /> <input type="text" id="ssnId" name="ssn" /> </body> </html> ,并且在所有服务器之间都使用stagit。我在this答案中找到了可在我的服务器上运行的配置(按工作原理,我的意思是nginx将通过Web浏览器将html提供给任何连接,但是如果我使用{{1} }。

我遇到的问题是,当我以来源git-http-backend推送此存储库(无论是来自服务器本身还是来自本地计算机)时,我收到403错误,不知道为什么。有什么想法吗?

nginx

大约两个小时前,我才开始尝试使用git clone https://git.website.com/test.git进行多个配置。让http正常服务网页似乎非常困难,但是允许git复制/推送。使用发现的here配置会产生200条OK响应空...

解决方法

经过反复试验,我从this答案中获取了配置,并对其进行了修改,以提供以下位置规则:

location / {
    if ($arg_service = git-receive-pack) {
        rewrite (/.*) /git_write/$1 last;
    }

    if ($uri ~ ^/.*/git-receive-pack$) {
        rewrite (/.*) /git_write/$1 last;
    }

    if ($arg_service = git-upload-pack) {
        rewrite (/.*) /git_read/$1 last;
    }

    if ($uri ~ ^/.*/git-upload-pack$) {
        rewrite (/.*) /git_read/$1 last;
    }
}

# pass PHP scripts to FastCGI server
location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}

location ~ /git_read/(.*) {
    include git-http-backend.conf;
}

# require auth to upload
location ~ /git_write/(.*) {
    auth_basic "Pushing to Git repositories is restricted";
    auth_basic_user_file /etc/nginx/htpasswd;
    include git-http-backend.conf;
}

/etc/nginx/git-http-backend.conf的内容如下:

fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /srv/git;
fastcgi_param PATH_INFO $1;
fastcgi_param REMOTE_USER $remote_user;

问题解决了。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...