我部署了一个 nginx git 服务器,只想请求授权进行推送。尝试了很多解决方案,但都不起作用。这是我的服务器配置
server {
root /var/www/mysite;
index index.html index.htm index.nginx-debian.html;
server_name www.mysite.com mysite.com;
location / {
try_files $uri $uri/ =404;
}
server {
root /var/www/git;
error_log /var/www/git/gitservererror.log;
access_log /var/www/git/gitserveraccess.log;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name git.mysite.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ /git(/.*) {
# fcgiwrap is set up to listen on this host:port
fastcgi_pass unix:/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
# export all repositories under GIT_PROJECT_ROOT
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /var/www/git;
fastcgi_param PATH_INFO $1;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/git.cassioavila.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/git.cassioavila.xyz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
server_name www.mysite.com mysite.com;
return 404; # managed by Certbot
}
server {
if ($host = git.mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name git.mysite.com;
return 404; # managed by Certbot
}
我将真实网站名称更改为 mysite.com。我尝试使用正则表达式,但我不太熟悉它。