git push: en-tête d’hôte requirejs manquant pour héberger le référentiel GitLab

Lorsque j’essaie de git push -u origin master vers mon repository, j’obtiens 400 Bad Request . J’ai délibérément rédigé des informations avec . Récemment dégroupé nginx de gitlab-ee, et vérifié l’accessibilité via un navigateur Web à l’emplacement gitlab. J’ai également essayé de définir l’URL à distance de git sur https://gitlab..com//project.git et la même chose se produit.

Erreur lors de la tentative de git push

remote: 400 Bad Request: missing required Host header fatal: unable to access 'https://oauth2:.site.com//project.git/': The requested URL returned error: 400

configuration nginx

 upstream gitlab { server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket; } upstream gitlab-workhorse { server unix://var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0; #server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socketfail_timeout=0; } map $http_upgrade $connection_upgrade_gitlab { default upgrade; '' close; } log_format gitlab_access $remote_addr - $remote_user [$time_local]"$request_method $gitlab_filtere$ map $request_uri $gitlab_temp_request_uri_1 { default $request_uri; ~(?i)^(?.*)(?[\?&]private[\-_]token)=[^&]*(?.*)$"$start$temp=[FILTERED]$rest"; } map $gitlab_temp_request_uri_1 $gitlab_temp_request_uri_2 { default $gitlab_temp_request_uri_1; ~(?i)^(?.*)(?[\?&]authenticity[\-_]token)=[^&]*(?.*)$"$start$temp=[FILTERED]$$ } map $gitlab_temp_request_uri_2 $gitlab_filtered_request_uri { default $gitlab_temp_request_uri_2; ~(?i)^(?.*)(?[\?&]rss[\-_]token)=[^&]*(?.*)$"$start$temp=[FILTERED]$rest"; } map $http_referer $gitlab_filtered_http_referer { default $http_referer; ~^(?.*)\? $temp; } server { server_name gitlab..com www.gitlab..com; server_tokens off; root /opt/gitlab/embedded/service/gitlab-rails/public; real_ip_header X-Real-IP; real_ip_recursive off; access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; passenger_ruby /opt/gitlab/embedded/bin/ruby; passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin"; passenger_user git; passenger_group git; passenger_enabled on; passenger_min_instances 1; location @gitlab-workhorse { ## https://github.com/gitlabhq/gitlabhq/issues/694 ## Some requests take more than 30 seconds. proxy_read_timeout 3600; proxy_connect_timeout 300; proxy_redirect off; # Do not buffer Git HTTP responses proxy_buffering off; proxy_set_header Host $http_host_with_default; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://gitlab-workhorse; ## The following settings only work with NGINX 1.7.11 or newer # ## Pass chunked request bodies to gitlab-workhorse as-is # proxy_request_buffering off; proxy_http_version 1.1; } location ~ ^/(assets)/ { root /opt/gitlab/embedded/service/gitlab-rails/public; gzip_static on; # to serve pre-gzipped version expires max; add_header Cache-Control public; } location / { client_max_body_size 0; gzip off; proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade_gitlab; proxy_pass http://gitlab; } error_page 404 /404.html; error_page 422 /422.html; error_page 500 /500.html; error_page 502 /502.html; error_page 503 /503.html; location ~ ^/(404|422|500|502|503)\.html$ { # Location to the Gitlab's public directory, # for Omnibus this would be: /opt/gitlab/embedded/service/gitlab-rails/public. root /home/git/gitlab/public; internal; } listen 443 ssl; # managed by Certbot ssl_certificatee /etc/letsencrypt/live/gitlab..com/fullchain.pem; # managed by Certb$ ssl_certificatee_key /etc/letsencrypt/live/gitlab..com/privkey.pem; # managed by Cer$ include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { listen 80; server_name www.gitlab..com gitlab..com; return 301 https://$host$request_uri; if ($host = www.gitlab..com) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = gitlab..com) { return 301 https://$host$request_uri; } # managed by Certbot } 

gitlab.rb config

 external_url 'https://gitlab..com' nginx['enable'] = false web_server['external_users'] = ['www-data'] gitlab_rails['trusted_proxies'] = [ '/24'] 

Donc, je l’ai compris en regardant de plus près la documentation de GitLab: https://docs.gitlab.com/omnibus/settings/nginx.html#vhost-server-block

J’ai négligé ces deux parameters. Ceci est à l’intérieur du bloc serveur principal.

 # For protocol upgrades from HTTP/1.0 to HTTP/1.1 we need to provide Host header if its missing if ($http_host = "") { # use one of values defined in server_name set $http_host_with_default "git.example.com"; } if ($http_host != "") { set $http_host_with_default $http_host; } 

De plus, j’ai supprimé client_max_body_size de location / { ... } et l’ai placé dans la scope parent.

Enfin, j’ai ajouté gitlab_rails['internal_api_url'] = 'https://gitlab..com' au fichier de configuration gitlab.rb .

Tout fonctionne maintenant comme il se doit.