{"id":628,"date":"2015-03-05T03:05:35","date_gmt":"2015-03-05T08:05:35","guid":{"rendered":"http:\/\/zhanxw.com\/blog\/?p=628"},"modified":"2016-02-25T19:24:39","modified_gmt":"2016-02-26T01:24:39","slug":"%e8%ae%be%e7%bd%ae%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/zhanxw.com\/blog\/2015\/03\/%e8%ae%be%e7%bd%ae%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8\/","title":{"rendered":"\u8bbe\u7f6e\u4ee3\u7406\u670d\u52a1\u5668"},"content":{"rendered":"<p>\u8bbe\u7f6e\u4ee3\u7406\u670d\u52a1\u5668<br \/>\nSetting up proxy<\/p>\n<p>\u51fa\u4e8e\u5bf9\u60a3\u8005\u4fe1\u606f\u7684\u4fdd\u62a4\uff0c\u5b66\u6821\u5185\u7f51\u63a5\u5165Internet\u65f6\u5fc5\u987b\u4f7f\u7528\u4ee3\u7406\uff08Proxy\uff09\u3002<br \/>\n\u8fd9\u4ee4\u5f88\u591a\u8f6f\u4ef6\u7684\u5b89\u88c5\u4f7f\u7528\u8fc7\u7a0b\u53d8\u5f97\u590d\u6742\u3002<\/p>\n<p>\u8fd9\u4e2a\u5e16\u5b50\u4f1a\u5217\u51fa\u7ed9\u5e38\u7528\u8f6f\u4ef6\u8bbe\u7f6e\u4ee3\u7406\u7684\u65b9\u6cd5\u3002<\/p>\n<p><strong>R<\/strong><\/p>\n<p>\u6700\u76f4\u63a5\u7684\u8bbe\u7f6e\u4ee3\u7406\u7684\u65b9\u6cd5\u662f\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a http_proxy, https_proxy\uff0c \u4f8b\u5982\uff1a <\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\nSys.setenv(http_proxy=&quot;http:\/\/proxy.swmed.edu:3128&quot;)\r\nSys.setenv(https_proxy=&quot;http:\/\/proxy.swmed.edu:3128&quot;)\r\n<\/pre>\n<p>\u5982\u679c\u4e0a\u8ff0\u65b9\u6cd5\u4e0d\u8d77\u4f5c\u7528\uff0c\u4e5f\u6709\u53ef\u80fd\u9700\u8981\uff1a<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n# In R, a partial solution is to use:\r\noptions(download.file.method=&quot;wget&quot;)\r\n<\/pre>\n<p>\u8fd9\u662f\u5728curl\u4e0d\u80fd\u6b63\u5e38\u4f7f\u7528\u4ee3\u7406\uff0c\u4f46wget\u53ef\u4ee5\u7528\u7684\u65f6\u5019\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u79cd\u60c5\u51b5\u662f\u7528devtools\u5b89\u88c5R\u7684\u6269\u5c55\u5305\uff0c\u53ef\u4ee5\u7528\uff1a<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\n\uff03 For devtools\r\nlibrary(httr)\r\nset_config(\r\n  use_proxy(url=&quot;proxy.swmed.edu&quot;, port=3128)\r\n)\r\n<\/pre>\n<p>\u5982\u679cMac\u7535\u8111\u4e0a\u6ca1\u6709\u5b89\u88c5X11\uff0c\u88c5package\u65f6\u9700\u8981\u6307\u5b9arepository\uff08<a href=\"http:\/\/stackoverflow.com\/questions\/11488174\/how-to-select-a-cran-mirror-in-r\" title=\"\u6765\u6e90\">\u6765\u6e90<\/a>\uff09\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"brush: r; title: ; notranslate\" title=\"\">\r\ninstall.packages('RMySQL', repos='http:\/\/cran.us.r-project.org')\r\n<\/pre>\n<p><strong>Docker<\/strong><\/p>\n<p>\u5f88\u591a\u8f6f\u4ef6\u63d0\u4f9b\u4e86Dockerfile\u3002\u7528\u6237\u9700\u8981\u4f7f\u7528docker build\u6765\u5236\u4f5c\u81ea\u5df1\u7684\u5bb9\u5668\uff08docker\uff09\u3002<br \/>\n\u5982\u679c\u5728\u9632\u706b\u5899\u540e\u9762\uff0c \u7b80\u5355\u7684\u65b9\u6cd5\u662f\u7528\uff08<a href=\"https:\/\/github.com\/docker\/docker\/issues\/14634\">link<\/a>\uff09\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndocker build \r\n  --build-arg https_proxy=$HTTP_PROXY --build-arg http_proxy=$HTTP_PROXY \r\n  --build-arg HTTP_PROXY=$HTTP_PROXY --build-arg HTTPS_PROXY=$HTTP_PROXY \r\n  --build-arg NO_PROXY=$NO_PROXY  --build-arg no_proxy=$NO_PROXY -t java .\r\n<\/pre>\n<p>\u53e6\u5916\u4e00\u4e2a\u65b9\u6cd5\u662f\u624b\u52a8\u4fee\u6539Dockerfile\uff0c\u52a0\u5165ENV\u8bed\u53e5\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nENV HTTP_PROXY http:\/\/proxy.swmed.edu\r\nENV HTTPS_PROXY http:\/\/proxy.swmed.edu\r\nENV http_proxy http:\/\/proxy.swmed.edu\r\nENV https_proxy http:\/\/proxy.swmed.edu\r\n....\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbe\u7f6e\u4ee3\u7406\u670d\u52a1\u5668 Setting up proxy \u51fa\u4e8e\u5bf9\u60a3\u8005\u4fe1\u606f\u7684\u4fdd\u62a4\uff0c\u5b66\u6821\u5185\u7f51\u63a5\u5165Internet\u65f6\u5fc5\u987b\u4f7f\u7528\u4ee3\u7406\uff08Proxy\uff09\u3002 \u8fd9\u4ee4\u5f88\u591a\u8f6f\u4ef6\u7684\u5b89\u88c5\u4f7f\u7528\u8fc7\u7a0b\u53d8\u5f97\u590d\u6742\u3002 \u8fd9\u4e2a\u5e16\u5b50\u4f1a\u5217\u51fa\u7ed9\u5e38\u7528\u8f6f\u4ef6\u8bbe\u7f6e\u4ee3\u7406\u7684\u65b9\u6cd5\u3002 R \u6700\u76f4\u63a5\u7684\u8bbe\u7f6e\u4ee3\u7406\u7684\u65b9\u6cd5\u662f\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a http_proxy, https_proxy\uff0c \u4f8b\u5982\uff1a Sys.setenv(http_proxy=&quot;http:\/\/proxy.swmed.edu:3128&quot;) Sys.setenv(https_proxy=&quot;http:\/\/proxy.swmed.edu:3128&quot;) \u5982\u679c\u4e0a\u8ff0\u65b9\u6cd5\u4e0d\u8d77\u4f5c\u7528\uff0c\u4e5f\u6709\u53ef\u80fd\u9700\u8981\uff1a # In R, a partial solution is to use: options(download.file.method=&quot;wget&quot;) \u8fd9\u662f\u5728curl\u4e0d\u80fd\u6b63\u5e38\u4f7f\u7528\u4ee3\u7406\uff0c\u4f46wget\u53ef\u4ee5\u7528\u7684\u65f6\u5019\u7684\u89e3\u51b3\u65b9\u6848\u3002 \u8fd8\u6709\u4e00\u79cd\u60c5\u51b5\u662f\u7528devtools\u5b89\u88c5R\u7684\u6269\u5c55\u5305\uff0c\u53ef\u4ee5\u7528\uff1a \uff03 For devtools library(httr) set_config( use_proxy(url=&quot;proxy.swmed.edu&quot;, port=3128) ) \u5982\u679cMac\u7535\u8111\u4e0a\u6ca1\u6709\u5b89\u88c5X11\uff0c\u88c5package\u65f6\u9700\u8981\u6307\u5b9arepository\uff08\u6765\u6e90\uff09\uff0c\u6bd4\u5982\uff1a install.packages(&#8216;RMySQL&#8217;, repos=&#8217;http:\/\/cran.us.r-project.org&#8217;) Docker \u5f88\u591a\u8f6f\u4ef6\u63d0\u4f9b\u4e86Dockerfile\u3002\u7528\u6237\u9700\u8981\u4f7f\u7528docker build\u6765\u5236\u4f5c\u81ea\u5df1\u7684\u5bb9\u5668\uff08docker\uff09\u3002 \u5982\u679c\u5728\u9632\u706b\u5899\u540e\u9762\uff0c \u7b80\u5355\u7684\u65b9\u6cd5\u662f\u7528\uff08link\uff09\uff1a docker build &#8211;build-arg https_proxy=$HTTP_PROXY &#8211;build-arg http_proxy=$HTTP_PROXY &#8211;build-arg HTTP_PROXY=$HTTP_PROXY &#8211;build-arg HTTPS_PROXY=$HTTP_PROXY &#8211;build-arg NO_PROXY=$NO_PROXY [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[69,45],"class_list":["post-628","post","type-post","status-publish","format-standard","hentry","category-sysadmin","tag-proxy","tag-r"],"_links":{"self":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/comments?post=628"}],"version-history":[{"count":0,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/628\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/media?parent=628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/categories?post=628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/tags?post=628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}