깃랩 웹토큰 문제 해결기록 solve gitlab personal Access token problem

깃랩 repository clone을 받으려는데 ssh는 연결이 가능하지만, 웹토큰을 이용한 접근은 계속 막혔다.

현상: 클론시 password 입력에서 토큰값을 입력해도 아래와 같이 뜸

remote: Nil JSON web token
fatal: unable to access 'https://gitlab.mydomain/username/remoterepository.git/': The requested URL returned error: 403

토큰 scope, 유효성은 문제없음

원인을 파악해보니 아래 call 과정에서 gitlab-workhorse가 포트로 떠있는 게 아니라서 문제가 되는 것으로 보임

Client HTTPS request
        ↓
   외부 nginx (443)
        ↓ proxy_pass
   gitlab-workhorse (Unix socket)
        ↓
     Rails / Gitaly

nginx config를 수정

root@silvercodeserver02:/# vi /etc/nginx/sites-available/gitlab 


location / 블록에 아래줄을 추가(기존 proxy_pass 설정은 주석)
proxy_pass http://unix:/var/opt/gitlab/gitlab-workhorse/sockets/socket;



root@silvercodeserver02:/# rm /etc/nginx/sites-enabled/gitlab 
root@silvercodeserver02:/# ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/
root@silvercodeserver02:/# systemctl restart nginx

해결!

secondpage@secondpageui-MacBookPro delete % git clone https://gitlab.mydomain.com/username/my_lib.git
'my_lib'에 복제합니다...
Username for 'https://gitlab.mydomain.com': username
Password for 'https://username@gitlab.mydomain.com': 
remote: Enumerating objects: 498, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 498 (delta 6), reused 0 (delta 0), pack-reused 478 (from 1)
오브젝트를 받는 중: 100% (498/498), 35.43 MiB | 38.03 MiB/s, 완료.
델타를 알아내는 중: 100% (191/191), 완료.