{"id":57928,"date":"2023-10-21T18:34:31","date_gmt":"2023-10-21T10:34:31","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=57928"},"modified":"2023-10-21T18:34:36","modified_gmt":"2023-10-21T10:34:36","slug":"%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9gitlab%e7%9a%84http%e6%88%96https%e7%ab%af%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/57928.html","title":{"rendered":"\u5982\u4f55\u4fee\u6539GitLab\u7684HTTP\u6216HTTPS\u7aef\u53e3"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\">\n<p>\u672c\u6587\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4fee\u6539GitLab\u7684HTTP\u6216HTTPS\u7aef\u53e3\uff1a1.\u7406\u89e3\u9ed8\u8ba4\u7aef\u53e3\u8bbe\u7f6e\uff1b2.\u8bbf\u95eeGitLab\u7684\u914d\u7f6e\u6587\u4ef6\uff1b3.\u4fee\u6539\u7aef\u53e3\u4fe1\u606f\uff1b4.\u91cd\u65b0\u542f\u52a8GitLab\u4ee5\u5e94\u7528\u66f4\u6539\uff1b5.\u9a8c\u8bc1\u4fee\u6539\u662f\u5426\u6210\u529f\u3002\u5728\u914d\u7f6eGitLab\u65f6\uff0c\u6709\u65f6\u53ef\u80fd\u9700\u8981\u8c03\u6574\u9ed8\u8ba4\u7684HTTP\u6216HTTPS\u7aef\u53e3\u4ee5\u9002\u5e94\u7279\u5b9a\u7684\u7f51\u7edc\u73af\u5883\u6216\u5b89\u5168\u7b56\u7565\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u7406\u89e3\u9ed8\u8ba4\u7aef\u53e3\u8bbe\u7f6e<\/h2>\n\n\n\n<p>GitLab\u9ed8\u8ba4\u4f7f\u7528HTTP\u7aef\u53e380\u548cHTTPS\u7aef\u53e3443\u3002\u8fd9\u4e9b\u9ed8\u8ba4\u8bbe\u7f6e\u5728\u5927\u591a\u6570\u73af\u5883\u4e2d\u662f\u9002\u7528\u7684\uff0c\u4f46\u5728\u67d0\u4e9b\u7279\u6b8a\u60c5\u5883\u4e2d\uff0c\u4f8b\u5982\u5f53\u7aef\u53e3\u51b2\u7a81\u6216\u7279\u5b9a\u7684\u5b89\u5168\u7b56\u7565\u9700\u6c42\u51fa\u73b0\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u4fee\u6539\u8fd9\u4e9b\u7aef\u53e3\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u8bbf\u95eeGitLab\u7684\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<p>\u8981\u4fee\u6539GitLab\u7684\u7aef\u53e3\u8bbe\u7f6e\uff0c\u9996\u5148\u9700\u8981\u8bbf\u95eeGitLab\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\uff0c\u5373<strong>gitlab.rb<\/strong>\u3002\u8fd9\u4e2a\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e<strong>\/etc\/gitlab<\/strong>\u76ee\u5f55\u4e2d\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4efb\u610f\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u5b83\uff0c\u4f8b\u5982<strong>vim<\/strong>\u6216<strong>nano<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/gitlab\/gitlab.rb<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u4fee\u6539\u7aef\u53e3\u4fe1\u606f<\/h2>\n\n\n\n<p>\u5728<strong>gitlab.rb<\/strong>\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u4e24\u884c\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>external_url 'http:\/\/gitlab.example.com'<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u4fee\u6539HTTP\u7aef\u53e3\uff0c\u53ef\u4ee5\u66f4\u6539\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>external_url 'http:\/\/gitlab.example.com:YOUR_PORT'<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d<strong>YOUR_PORT<\/strong>\u662f\u4f60\u5e0c\u671b\u8bbe\u7f6e\u7684\u65b0\u7aef\u53e3\u53f7\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f7f\u7528HTTPS\u5e76\u5e0c\u671b\u66f4\u6539\u5176\u7aef\u53e3\uff0c\u786e\u4fdd\u5728URL\u524d\u6709<strong>https<\/strong>\u534f\u8bae\uff0c\u5e76\u6309\u7167\u76f8\u540c\u7684\u65b9\u5f0f\u4fee\u6539\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>external_url 'https:\/\/gitlab.example.com:YOUR_PORT'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u91cd\u65b0\u542f\u52a8GitLab\u4ee5\u5e94\u7528\u66f4\u6539<\/h2>\n\n\n\n<p>\u4fee\u6539\u7aef\u53e3\u8bbe\u7f6e\u540e\uff0c\u5fc5\u987b\u91cd\u65b0\u914d\u7f6e\u5e76\u91cd\u542fGitLab\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo gitlab-ctl reconfigure sudo gitlab-ctl restart<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5.\u9a8c\u8bc1\u4fee\u6539\u662f\u5426\u6210\u529f<\/h2>\n\n\n\n<p>\u4e00\u65e6GitLab\u91cd\u542f\uff0c\u5c1d\u8bd5\u8bbf\u95eeGitLab\u7684\u65b0URL\uff08\u8bb0\u4f4f\u5305\u62ec\u65b0\u7684\u7aef\u53e3\u53f7\uff09\u4ee5\u786e\u4fdd\u66f4\u6539\u5df2\u6210\u529f\u5e94\u7528\u3002\u5982\u679c\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u5e76\u4e14\u6ca1\u6709\u9519\u8bef\u6d88\u606f\uff0c\u90a3\u4e48\u7aef\u53e3\u4fee\u6539\u5c31\u5df2\u6210\u529f\u3002<\/p>\n\n\n\n<p>\u603b\u4e4b\uff0c\u4fee\u6539GitLab\u7684HTTP\u6216HTTPS\u7aef\u53e3\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u4f46\u9700\u8981\u786e\u4fdd\u6b63\u786e\u5730\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u65b0\u542f\u52a8\u670d\u52a1\u3002\u6b64\u5916\uff0c\u6bcf\u6b21\u4fee\u6539\u914d\u7f6e\u65f6\uff0c\u5efa\u8bae\u5907\u4efd\u91cd\u8981\u7684\u914d\u7f6e\u6587\u4ef6\u4ee5\u9632\u6b62\u4efb\u4f55\u6f5c\u5728\u7684\u95ee\u9898\u3002\u5982\u679c\u5728\u7f51\u7edc\u73af\u5883\u6216\u5b89\u5168\u7b56\u7565\u4e2d\u6709\u7279\u5b9a\u7684\u9700\u6c42\uff0c\u53ef\u4ee5\u6309\u7167\u4e0a\u8ff0\u6b65\u9aa4\u66f4\u6539\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u4ee5\u786e\u4fddGitLab\u670d\u52a1\u5668\u7684\u6b63\u786e\u548c\u5b89\u5168\u8fd0\u884c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1280\" height=\"850\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u4e0b\u8f7dgithub\u7684\u6587\u4ef6-2023-10-21T182744.529.jpg?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\" class=\"wp-image-57929\" srcset=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u4e0b\u8f7dgithub\u7684\u6587\u4ef6-2023-10-21T182744.529.jpg 1280w, https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u4e0b\u8f7dgithub\u7684\u6587\u4ef6-2023-10-21T182744.529-768x510.jpg 768w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/figure>\n\n\n\n<p><strong>\u5e38\u89c1\u95ee\u7b54\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>Q1: \u6211\u5df2\u7ecf\u4fee\u6539\u4e86GitLab\u7684HTTP\u6216HTTPS\u7aef\u53e3\uff0c\u4e3a\u4ec0\u4e48\u6211\u4e0d\u80fd\u8bbf\u95eeGitLab\uff1f<\/strong><\/li>\n\n\n\n<li>A1: \u4fee\u6539\u7aef\u53e3\u540e\uff0c\u786e\u4fdd\u60a8\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\u7684URL\u5305\u542b\u65b0\u7684\u7aef\u53e3\u53f7\uff0c\u5982 <strong>http:\/\/your-gitlab-domain:NEW_PORT\/<\/strong>\u3002\u540c\u65f6\uff0c\u786e\u4fdd\u9632\u706b\u5899\u6216\u5b89\u5168\u7ec4\u89c4\u5219\u5141\u8bb8\u65b0\u7aef\u53e3\u7684\u4f20\u5165\u6d41\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Q2: \u4fee\u6539GitLab\u7aef\u53e3\u540e\uff0c\u6211\u5fc5\u987b\u5728\u54ea\u91cc\u66f4\u65b0Git\u7684\u8fdc\u7a0bURL\uff1f<\/strong><\/li>\n\n\n\n<li>A2: \u5982\u679c\u60a8\u5df2\u7ecf\u6709\u514b\u9686\u7684GitLab\u5b58\u50a8\u5e93\uff0c\u5e76\u4e14\u56e0\u66f4\u6539\u7aef\u53e3\u800c\u9700\u8981\u66f4\u65b0\u8fdc\u7a0bURL\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<strong>git remote set-url origin http:\/\/your-gitlab-domain:NEW_PORT\/your-repository.git<\/strong>\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>Q3: \u6211\u662f\u5426\u9700\u8981\u91cd\u542fGitLab\u6765\u5e94\u7528\u65b0\u7684\u7aef\u53e3\u8bbe\u7f6e\uff1f<\/strong><\/li>\n\n\n\n<li>A3: \u662f\u7684\uff0c\u4fee\u6539HTTP\u6216HTTPS\u7aef\u53e3\u540e\uff0c\u60a8\u9700\u8981\u91cd\u542fGitLab\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u672c\u6587\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4fee\u6539GitLab\u7684HTTP\u6216HTTPS\u7aef\u53e3\uff1a1.\u7406\u89e3\u9ed8\u8ba4\u7aef\u53e3\u8bbe\u7f6e\uff1b2.\u8bbf\u95eeGitLab\u7684\u914d\u7f6e\u6587 [&hellip;]","protected":false},"author":7,"featured_media":57930,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[2837,1226],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/57928"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=57928"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/57928\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/57930"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=57928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=57928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=57928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}