我已经浏览了类似文章中提供的答案,但是尝试连接到Connection refused
时仍然出现git.example.com
错误。
确切的nginx错误消息如下
2019/11/05 17:16:09 [error] 12175#12175: *1 connect() to unix:/tmp/fcgiwrap.sock failed (111: Connection refused) while connecting to upstream,client: xxx.xxx.xxx.xxx,server: git.example.com,request: "GET / HTTP/1.1",upstream: "fastcgi://unix:/tmp/fcgiwrap.sock:",host: "git.example.com",referrer: "https://example.com/"
ls -l /tmp/fcgiwrap.sock
给出
srwxrwxr-x 1 www-data www-data 0 Jul 3 00:56 /tmp/fcgiwrap.sock
我已通过chmod g+w /tmp/fcgiwrap.sock
授予了套接字文件的写权限。
ps aux | grep nginx
提供以下内容
root 11203 0.0 0.1 47572 1412 ? Ss 07:17 0:00 nginx: master process /usr/sbin/nginx
www-data 11204 0.0 0.6 47788 6116 ? S 07:17 0:01 nginx: worker process
www-data 11205 0.0 0.3 47572 2856 ? S 07:17 0:02 nginx: worker process
www-data 11206 0.0 0.4 47572 5632 ? S 07:17 0:02 nginx: worker process
www-data 11207 0.0 0.0 47572 2856 ? S 07:17 0:02 nginx: worker process
pi 11996 0.0 0.0 4733 576 ? S 07:17 0:01 grep nginx
Nginx用户为www-data
。我怀疑这是我的Nginx conf文件。请注意,我同时在端口443上监听了git.example.com
和example.com
,但是在我的DNS设置中有A
前缀的git
记录。
server {
listen 443 ssl;
server_name git.example.com;
location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
root /usr/share/nginx/example/git;
auth_basic "Restricted";
auth_basic_user_file /usr/share/nginx/example/.gitpasswd;
fastcgi_pass unix:/tmp/fcgiwrap.sock;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
fastcgi_param PATH_INFO $uri;
fastcgi_param GIT_PROJECT_ROOT /usr/share/nginx/example/git;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param REMOTE_USER $remote_user;
include fastcgi_params;
}
location /index.cgi {
root /usr/share/gitweb;
include fastcgi_params;
gzip off;
fastcgi_param SCRIPT_NAME $uri;
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
fastcgi_pass unix:/tmp/fcgiwrap.sock;
}
location / {
root /usr/share/gitweb;
index index.cgi;
}
ssl_certificate /.../fullchain.pem;
ssl_certificate /.../privkey.pem;
}
请注意,我安装并运行了fcgiwrap
,尽管给了我一个设置区域设置失败的错误-它会自动回退到后备区域设置(“ en_GB.UTF-8”)。