{"id":1452,"date":"2024-10-23T10:22:59","date_gmt":"2024-10-23T02:22:59","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=1452"},"modified":"2024-10-23T10:22:59","modified_gmt":"2024-10-23T02:22:59","slug":"linux-%e4%b8%8a%e7%9a%84-http-proxy","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=1452","title":{"rendered":"linux \u4e0a\u7684 http proxy"},"content":{"rendered":"<p>\u5728 Linux \u4e0a\u914d\u7f6e HTTP \u4ee3\u7406\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u8fdb\u884c\uff1a<\/p>\n<h3>1. <strong>\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u914d\u7f6e<\/strong><\/h3>\n<p>\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u8bbe\u7f6e HTTP \u548c HTTPS \u4ee3\u7406\u3002\u53ef\u4ee5\u7f16\u8f91\u7528\u6237\u7684 shell \u914d\u7f6e\u6587\u4ef6\uff08\u4f8b\u5982 <code>.bashrc<\/code> \u6216 <code>.zshrc<\/code>\uff09\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">\nexport http_proxy=http:\/\/proxy_server_address:proxy_port\nexport https_proxy=https:\/\/proxy_server_address:proxy_port\nexport ftp_proxy=ftp:\/\/proxy_server_address:proxy_port\nexport no_proxy=\"localhost,127.0.0.1,::1\"\n\n    \u2022   proxy_server_address: \u4ee3\u7406\u670d\u52a1\u5668\u7684\u5730\u5740\u3002\n    \u2022   proxy_port: \u4ee3\u7406\u670d\u52a1\u5668\u7684\u7aef\u53e3\u3002\n    \u2022   no_proxy: \u4e0d\u4f7f\u7528\u4ee3\u7406\u7684\u5730\u5740\uff0c\u901a\u5e38\u662f\u672c\u5730 IP\u3002\n\n\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\uff1a\n\nsource ~\/.bashrc  # \u6216 source ~\/.zshrc\n\n2. \u4e3a\u7279\u5b9a\u7a0b\u5e8f\u914d\u7f6e\n\n\u6709\u4e9b\u7a0b\u5e8f\u5141\u8bb8\u5728\u5176\u914d\u7f6e\u6587\u4ef6\u4e2d\u5355\u72ec\u914d\u7f6e\u4ee3\u7406\uff0c\u4f8b\u5982 curl \u548c git\u3002\n\n\u914d\u7f6e curl \u4ee3\u7406\n\n\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u884c\u4e3a curl \u914d\u7f6e\u4ee3\u7406\uff1a\n\ncurl -x http:\/\/proxy_server_address:proxy_port http:\/\/example.com\n\n\u4e5f\u53ef\u4ee5\u5728 ~\/.curlrc \u4e2d\u8bbe\u7f6e\uff1a\n\nproxy = http:\/\/proxy_server_address:proxy_port\n\n\u914d\u7f6e git \u4ee3\u7406\n\n\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4e3a git \u914d\u7f6e\u5168\u5c40\u4ee3\u7406\uff1a\n\ngit config --global http.proxy http:\/\/proxy_server_address:proxy_port\ngit config --global https.proxy https:\/\/proxy_server_address:proxy_port\n\n\u8981\u5220\u9664\u4ee3\u7406\u914d\u7f6e\uff0c\u53ef\u4ee5\u6267\u884c\uff1a\n\ngit config --global --unset http.proxy\ngit config --global --unset https.proxy\n\n3. \u901a\u8fc7 apt \u914d\u7f6e\uff08\u9002\u7528\u4e8e Debian\/Ubuntu\uff09\n\n\u5982\u679c\u4f7f\u7528 apt \u8fdb\u884c\u8f6f\u4ef6\u5305\u7ba1\u7406\uff0c\u53ef\u4ee5\u4e3a\u5176\u914d\u7f6e\u4ee3\u7406\u3002\u5728 \/etc\/apt\/apt.conf.d\/ \u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5982 proxy.conf\uff09\uff0c\u5e76\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\uff1a\n\nAcquire::http::Proxy \"http:\/\/proxy_server_address:proxy_port\/\";\nAcquire::https::Proxy \"https:\/\/proxy_server_address:proxy_port\/\";\n\n4. \u901a\u8fc7 GNOME \u7f51\u7edc\u8bbe\u7f6e\u914d\u7f6e\n\n\u5bf9\u4e8e\u4f7f\u7528 GNOME \u684c\u9762\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7\u56fe\u5f62\u754c\u9762\u914d\u7f6e\u4ee3\u7406\uff1a\n\n    1.  \u6253\u5f00 \u201c\u8bbe\u7f6e\u201d > \u201c\u7f51\u7edc\u201d\u3002\n    2.  \u5728\u7f51\u7edc\u8bbe\u7f6e\u9875\u9762\u5e95\u90e8\u627e\u5230 \u201c\u7f51\u7edc\u4ee3\u7406\u201d\u3002\n    3.  \u9009\u62e9 \u201c\u624b\u52a8\u201d \u5e76\u8f93\u5165 HTTP\u3001HTTPS\u3001FTP \u4ee3\u7406\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3\u3002\n\n\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u4e3a\u7cfb\u7edf\u6216\u7279\u5b9a\u5e94\u7528\u914d\u7f6e HTTP \u4ee3\u7406\u3002<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Linux \u4e0a\u914d\u7f6e HTTP \u4ee3\u7406\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u8fdb\u884c\uff1a 1. \u5728\u73af\u5883\u53d8\u91cf\u4e2d\u914d\u7f6e \u5e38\u7528\u7684\u65b9\u6cd5\u662f\u5728\u73af\u5883\u53d8\u91cf\u4e2d\u8bbe\u7f6e HTTP \u548c HTTPS \u4ee3\u7406\u3002\u53ef\u4ee5\u7f16\u8f91\u7528\u6237\u7684 shell \u914d\u7f6e\u6587\u4ef6\uff08\u4f8b\u5982 .bashrc \u6216 .zshrc\uff09\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a export http_proxy=http:\/\/proxy_server_address:proxy_port export https_proxy=https:\/\/proxy_server_address:proxy_port export ftp_proxy=ftp:\/\/proxy_server_address:proxy_port export no_proxy=&#8221;localhost,127.0.0.1,::1&#8243; \u2022 proxy_server_address: \u4ee3\u7406\u670d\u52a1\u5668\u7684\u5730\u5740\u3002 \u2022 proxy_port: \u4ee3\u7406\u670d\u52a1\u5668\u7684\u7aef\u53e3\u3002 \u2022 no_proxy: \u4e0d\u4f7f\u7528\u4ee3\u7406\u7684\u5730\u5740\uff0c\u901a\u5e38\u662f\u672c\u5730 IP\u3002 \u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\uff1a source ~\/.bashrc # \u6216 source ~\/.zshrc 2. \u4e3a\u7279\u5b9a\u7a0b\u5e8f\u914d\u7f6e \u6709\u4e9b\u7a0b\u5e8f\u5141\u8bb8\u5728\u5176\u914d\u7f6e\u6587\u4ef6\u4e2d\u5355\u72ec\u914d\u7f6e\u4ee3\u7406\uff0c\u4f8b\u5982 curl \u548c git\u3002 \u914d\u7f6e curl \u4ee3\u7406 \u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u884c\u4e3a curl \u914d\u7f6e\u4ee3\u7406\uff1a curl [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=1452\" title=\"Permanent Link to: linux \u4e0a\u7684 http proxy\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1452","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1452"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1452"}],"version-history":[{"count":1,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1452\/revisions"}],"predecessor-version":[{"id":1453,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1452\/revisions\/1453"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}