{"id":18965,"date":"2024-11-19T15:57:05","date_gmt":"2024-11-19T07:57:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18965\/"},"modified":"2024-11-19T15:57:05","modified_gmt":"2024-11-19T07:57:05","slug":"%e8%af%a6%e8%a7%a3%e5%a6%82%e4%bd%95%e6%90%ad%e5%bb%bagithub%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18965\/","title":{"rendered":"\u8be6\u89e3\u5982\u4f55\u642d\u5efaGitHub\u670d\u52a1\u5668"},"content":{"rendered":"<p>github\u662f\u5168\u7403\u6700\u53d7\u6b22\u8fce\u7684\u4ee3\u7801\u6258\u7ba1\u5e73\u53f0\u4e4b\u4e00\uff0c\u62e5\u6709\u6570\u767e\u4e07\u7684\u6ce8\u518c\u7528\u6237\u548c\u6570\u767e\u4e07\u7684\u5f00\u6e90\u4ee3\u7801\u5e93\u3002\u4f46\u662f\uff0c\u5bf9\u4e8e\u4f01\u4e1a\u6216\u4e2a\u4eba\u800c\u8a00\uff0c\u5c06\u4ee3\u7801\u6258\u7ba1\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u53ef\u4ee5\u63d0\u9ad8\u5b89\u5168\u6027\u548c\u6570\u636e\u63a7\u5236\u6027\u3002\u56e0\u6b64\uff0c\u672c\u6587\u5c06\u4f1a\u4ecb\u7ecd\u5982\u4f55\u642d\u5efagithub\u670d\u52a1\u5668\u3002<\/p>\n<p>\u4e00\u3001\u73af\u5883\u51c6\u5907<\/p>\n<p>1.\u786c\u4ef6\u51c6\u5907<\/p>\n<p>GitHub\u670d\u52a1\u5668\u6240\u9700\u7684\u786c\u4ef6\u8981\u6c42\u5e76\u4e0d\u662f\u5f88\u9ad8\uff0c\u901a\u5e38\u4e00\u53f0\u666e\u901a\u670d\u52a1\u5668\u5c31\u80fd\u80dc\u4efb\u3002\u4f46\u6700\u597d\u4fdd\u8bc1\u670d\u52a1\u5668\u7684\u5e26\u5bbd\u5927\u4e8e1Mbps\uff0c\u5e76\u4e14\u5b58\u5728\u8db3\u591f\u7684\u5b58\u50a8\u7a7a\u95f4\u4ee5\u5bb9\u7eb3\u4ee3\u7801\u5e93\u548c\u65e5\u5fd7\u7b49\u6570\u636e\u3002<\/p>\n<p>2.\u8f6f\u4ef6\u51c6\u5907<\/p>\n<p>\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\uff1a<\/p>\n<p>a. Git\u548c\u5176\u5b83\u5fc5\u8981\u7684\u5de5\u5177<\/p>\n<p>Git\u662fGitHub\u6700\u6838\u5fc3\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5\u5b83\u7684\u5ba2\u6237\u7aef\u3002<\/p>\n<p>b. SSH<\/p>\n<p>SSH\u662f\u56e0\u7279\u7f51\u4e0a\u7528\u4e8e\u5728\u4e0d\u5b89\u5168\u7684\u7f51\u7edc\u4e2d\u4e3a\u7f51\u7edc\u670d\u52a1\u63d0\u4f9b\u5b89\u5168\u8fde\u63a5\u7684\u4e00\u9879\u7f51\u7edc\u534f\u8bae\u3002\u9700\u8981\u5b89\u88c5SSH\u5ba2\u6237\u7aef\u7ec4\u4ef6\u3002<\/p>\n<p>c. Nginx<\/p>\n<p>Nginx\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684web\u670d\u52a1\u5668\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u3002\u9700\u8981\u5b89\u88c5\u5b83\u7528\u4e8e\u5bf9\u5916\u63d0\u4f9bHTTP\u670d\u52a1\u3002<\/p>\n<p>d. OpenSSL<\/p>\n<p>OpenSSL\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u52a0\u5bc6\u5e93\uff0c\u7528\u4e8e\u652f\u6301SSL\u548cTLS\u534f\u8bae\uff0c\u63d0\u4f9b\u5b89\u5168\u7684\u901a\u4fe1\u8fde\u63a5\u3002\u9700\u8981\u5b89\u88c5\u8be5\u5e93\u652f\u6301HTTPS\u534f\u8bae\u3002<\/p>\n<p>\u4e8c\u3001\u5b89\u88c5GitLab<\/p>\n<p>\u5728\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u597d\u4ee5\u4e0a\u8f6f\u4ef6\uff0c\u5e76\u4fdd\u8bc1\u5b83\u4eec\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<p>1.\u5b89\u88c5GitLab<\/p>\n<p>\u5728GitLab\u7684\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7684GitLab\u5b89\u88c5\u5305\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<p>sudo dpkg -i gitlab-ce_*_amd64.deb<\/p>\n<p>\u6ce8\u610f\uff1a\u8fd9\u91cc\u4f7f\u7528\u7684\u662fGitLab\u7684\u5f00\u6e90\u7248\u672cGitLab Community Edition\uff0c\u800c\u975e\u4f01\u4e1a\u7248\u3002<\/p>\n<p>2.\u914d\u7f6eGitLab<\/p>\n<p>1\uff09\u542f\u52a8GitLab<\/p>\n<p>\u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8GitLab\uff1a<\/p>\n<p>sudo gitlab-ctl reconfigure<\/p>\n<p>2\uff09\u8bbf\u95eeGitLab<\/p>\n<p>\u542f\u52a8\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eeGitLab\uff1ahttp:\/\/your-server-ip\/\uff0c\u8fdb\u884c\u7ba1\u7406\u5458\u8d26\u53f7\u7684\u521b\u5efa\uff0c\u5e76\u521b\u5efa\u65b0\u7684\u4ed3\u5e93\u3002<\/p>\n<p>3.\u914d\u7f6eNginx\u3001HTTPS<\/p>\n<p>1\uff09\u914d\u7f6eNginx<\/p>\n<p>\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5Nginx\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<p>sudo apt-get install nginx<\/p>\n<p>\u5728Nginx\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0GitLab\u7684\u914d\u7f6e\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>upstream gitlab-workhorse {<\/p>\n<p>server unix:\/var\/opt\/gitlab\/gitlab-workhorse\/socket;<\/p>\n<p>}<\/p>\n<p>server {<\/p>\n<p>listen 80;<\/p>\n<p>server_name your-domain.com;<\/p>\n<p>return 301 https:\/\/$server_name$request_uri;<\/p>\n<p>}<\/p>\n<p>server {<\/p>\n<p># Nginx\u76d1\u542c8080\u7aef\u53e3\uff0cGitLab Puma\u76d1\u542c8081\u7aef\u53e3<\/p>\n<p>listen 8080 default;<\/p>\n<p>server_name your-domain.com;<\/p>\n<p>## \u6027\u80fd\u4f18\u5316\u53ef\u4ee5\u4f7f\u7528\u914d\u7f6e<\/p>\n<p># server_tokens off;<\/p>\n<p>## ~\u5f00\u5934\u7684\u4e3a\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>## \/ci\u6b63\u5219\u4e3a\u5c06\u6240\u6709\u4e0e \/ci \u76f8\u5173\u7684\u8bf7\u6c42\u8f6c\u53d1\u5230 GitLab Puma HTTP \u670d\u52a1\u5668<\/p>\n<p>location \/ci {<\/p>\n<pre>proxy_read_timeout 300;\n\nproxy_connect_timeout 300;\n\nproxy_redirect off;\n\nproxy_http_version 1.1;\n\nproxy_set_header   X-Real-IP $remote_addr;\n\nproxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;\n\nproxy_set_header   Host $http_host;\n\nproxy_set_header   Connection '';\n\nproxy_pass http:\/\/127.0.0.1:8081;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>2\uff09\u521b\u5efaSSL\u8bc1\u4e66<\/p>\n<p>\u5728\u670d\u52a1\u5668\u4e0a\u9700\u8981\u521b\u5efa\u4e00\u4e2aSSL\u8bc1\u4e66\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout your-key-file.key -out your-ssl-file.crt<\/p>\n<p>\u5728Nginx\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0SSL\u8bc1\u4e66\u76f8\u5173\u7684\u914d\u7f6e\uff1a<\/p>\n<p>server {<\/p>\n<p># HTTPS \u76d1\u542c 443 \u7aef\u53e3<\/p>\n<p>listen 443 ssl;<\/p>\n<p>server_name your-domain.com;<\/p>\n<p>ssl_certificate \/path\/to\/your-ssl-file.crt;<\/p>\n<p>ssl_certificate_key \/path\/to\/your-key-file.key;<\/p>\n<p>## ~\u5f00\u5934\u7684\u4e3a\u6b63\u5219\u8868\u8fbe\u5f0f<\/p>\n<p>location \/ci {<\/p>\n<pre>proxy_read_timeout 300;\n\nproxy_connect_timeout 300;\n\nproxy_redirect off;\n\nproxy_http_version 1.1;\n\nproxy_set_header   X-Real-IP $remote_addr;\n\nproxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;\n\nproxy_set_header   Host $http_host;\n\nproxy_set_header   Connection '';\n\nproxy_pass http:\/\/127.0.0.1:8081;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u642d\u5efaGitHub\u670d\u52a1\u5668\uff0c\u6b65\u9aa4\u5206\u4e3a\uff1a\u73af\u5883\u51c6\u5907\u3001\u5b89\u88c5GitLab\u3001\u914d\u7f6eNginx\u3001\u914d\u7f6eHTTPS\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u9700\u8981\u642d\u5efaGitLab\u670d\u52a1\u5668\u7684\u8bfb\u8005\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8be6\u89e3\u5982\u4f55\u642d\u5efaGitHub\u670d\u52a1\u5668\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>github\u662f\u5168\u7403\u6700\u53d7\u6b22\u8fce\u7684\u4ee3\u7801\u6258\u7ba1\u5e73\u53f0\u4e4b\u4e00\uff0c\u62e5\u6709\u6570\u767e\u4e07\u7684\u6ce8\u518c\u7528\u6237\u548c\u6570\u767e\u4e07\u7684\u5f00\u6e90\u4ee3\u7801\u5e93\u3002\u4f46\u662f\uff0c\u5bf9\u4e8e\u4f01\u4e1a\u6216\u4e2a\u4eba\u800c\u8a00\uff0c\u5c06\u4ee3\u7801\u6258\u7ba1\u5728\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4e0a\u53ef\u4ee5\u63d0\u9ad8\u5b89\u5168\u6027\u548c\u6570\u636e\u63a7\u5236\u6027\u3002\u56e0\u6b64\uff0c\u672c\u6587\u5c06\u4f1a\u4ecb\u7ecd\u5982\u4f55\u642d\u5efagithub\u670d\u52a1\u5668\u3002 \u4e00\u3001\u73af\u5883\u51c6\u5907 1.\u786c\u4ef6\u51c6\u5907 GitHub\u670d\u52a1\u5668\u6240\u9700\u7684\u786c\u4ef6\u8981\u6c42\u5e76\u4e0d\u662f\u5f88\u9ad8\uff0c\u901a\u5e38\u4e00\u53f0\u666e\u901a\u670d\u52a1\u5668\u5c31\u80fd\u80dc\u4efb\u3002\u4f46\u6700\u597d\u4fdd\u8bc1\u670d\u52a1\u5668\u7684\u5e26\u5bbd\u5927\u4e8e1Mbps\uff0c\u5e76\u4e14\u5b58\u5728\u8db3\u591f\u7684\u5b58\u50a8\u7a7a\u95f4\u4ee5\u5bb9\u7eb3\u4ee3\u7801\u5e93\u548c\u65e5\u5fd7\u7b49\u6570\u636e\u3002 2.\u8f6f\u4ef6\u51c6\u5907 \u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\uff1a a. Git\u548c\u5176\u5b83\u5fc5\u8981\u7684\u5de5\u5177 Git\u662fGitHub\u6700\u6838\u5fc3\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5\u5b83\u7684\u5ba2\u6237\u7aef\u3002 b. SSH SSH\u662f\u56e0\u7279\u7f51\u4e0a\u7528\u4e8e\u5728\u4e0d\u5b89\u5168\u7684\u7f51\u7edc\u4e2d\u4e3a\u7f51\u7edc\u670d\u52a1\u63d0\u4f9b\u5b89\u5168\u8fde\u63a5\u7684\u4e00\u9879\u7f51\u7edc\u534f\u8bae\u3002\u9700\u8981\u5b89\u88c5SSH\u5ba2\u6237\u7aef\u7ec4\u4ef6\u3002 c. Nginx Nginx\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684web\u670d\u52a1\u5668\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u3002\u9700\u8981\u5b89\u88c5\u5b83\u7528\u4e8e\u5bf9\u5916\u63d0\u4f9bHTTP\u670d\u52a1\u3002 d. OpenSSL OpenSSL\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u52a0\u5bc6\u5e93\uff0c\u7528\u4e8e\u652f\u6301SSL\u548cTLS\u534f\u8bae\uff0c\u63d0\u4f9b\u5b89\u5168\u7684\u901a\u4fe1\u8fde\u63a5\u3002\u9700\u8981\u5b89\u88c5\u8be5\u5e93\u652f\u6301HTTPS\u534f\u8bae\u3002 \u4e8c\u3001\u5b89\u88c5GitLab \u5728\u5b89\u88c5GitLab\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u597d\u4ee5\u4e0a\u8f6f\u4ef6\uff0c\u5e76\u4fdd\u8bc1\u5b83\u4eec\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\u3002 1.\u5b89\u88c5GitLab \u5728GitLab\u7684\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7684GitLab\u5b89\u88c5\u5305\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a sudo dpkg -i gitlab-ce_*_amd64.deb \u6ce8\u610f\uff1a\u8fd9\u91cc\u4f7f\u7528\u7684\u662fGitLab\u7684\u5f00\u6e90\u7248\u672cGitLab Community Edition\uff0c\u800c\u975e\u4f01\u4e1a\u7248\u3002 2.\u914d\u7f6eGitLab 1\uff09\u542f\u52a8GitLab \u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8GitLab\uff1a sudo gitlab-ctl reconfigure 2\uff09\u8bbf\u95eeGitLab \u542f\u52a8\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eeGitLab\uff1ahttp:\/\/your-server-ip\/\uff0c\u8fdb\u884c\u7ba1\u7406\u5458\u8d26\u53f7\u7684\u521b\u5efa\uff0c\u5e76\u521b\u5efa\u65b0\u7684\u4ed3\u5e93\u3002 3.\u914d\u7f6eNginx\u3001HTTPS 1\uff09\u914d\u7f6eNginx \u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5Nginx\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a sudo apt-get install nginx \u5728Nginx\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0GitLab\u7684\u914d\u7f6e\uff0c\u5982\u4e0b\uff1a upstream gitlab-workhorse { server unix:\/var\/opt\/gitlab\/gitlab-workhorse\/socket; } server { listen 80; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-18965","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18965"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18965\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}