{"id":175573,"date":"2020-04-14T08:50:13","date_gmt":"2020-04-14T00:50:13","guid":{"rendered":"https:\/\/gulass.cn\/?p=175573"},"modified":"2020-03-27T09:50:57","modified_gmt":"2020-03-27T01:50:57","slug":"http-java-linux","status":"publish","type":"post","link":"https:\/\/gulass.cn\/http-java-linux.html","title":{"rendered":"\u6559\u4f60\u5982\u4f55\u57fa\u4e8ehttp\u4ee3\u7406\u89e3\u51b3Java\u56fa\u5b9aip\u95ee\u9898"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5982\u4f55\u57fa\u4e8ehttp\u4ee3\u7406\u89e3\u51b3Java\u56fa\u5b9aip\u95ee\u9898,\u6587\u4e2d\u901a\u8fc7\u793a\u4f8b\u4ee3\u7801\u4ecb\u7ecd\u7684\u975e\u5e38\u8be6\u7ec6\uff0c\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6216\u8005\u5de5\u4f5c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u5b66\u4e60\u4ef7\u503c,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b
\n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u80cc\u666f\uff1a\u5bf9\u63a5\u7b2c\u4e09\u65b9\u63a5\u53e3\uff0c\u7b2c\u4e09\u65b9\u4e3a\u5b89\u5168\u8003\u8651\uff0c\u9700\u8981\u56fa\u5b9aip\u8bbe\u7f6e\u767d\u540d\u5355\u3002\u516c\u53f8\u5bf9\u5916\u4f7f\u7528\u52a8\u6001ip\u3002<\/p>\n

\u529e\u6cd5\uff1a<\/p>\n

1. \u8d2d\u4e70\u4e00\u53f0ip\u56fa\u5b9a\u7684\u670d\u52a1\u5668\uff0c\u6bd4\u5982\u4e91\u865a\u62df\u670d\u52a1\u5668\u3002\u642d\u5efahttp\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u6bd4\u5982prioxy\u3002<\/p>\n

2.\u5b89\u88c5Privoxy\u4ee3\u7406\u8f6f\u4ef6<\/p>\n

yum install -y epel-release privoxy<\/pre>\n

\u7f16\u8f91 \/etc\/privoxy\/config \u6587\u4ef6<\/p>\n

\u4fee\u6539\u7ed1\u5b9a\u5730\u5740\uff0c\u641c\u7d22 listen-address \uff0c\u4fee\u6539\u9700\u8981\u7ed1\u5b9a\u7684IP<\/p>\n

listen-address 0.0.0.0:8118<\/pre>\n

\u8bbe\u7f6eenable-remote-toggle \u4e3a 1<\/p>\n

enable-remote-toggle 1<\/pre>\n

\u91cd\u542f\u670d\u52a1<\/p>\n

service privoxy restart<\/pre>\n

\u67e5\u770b\u670d\u52a1\u72b6\u6001<\/p>\n

[root@localhost ~]# service privoxy status\r\nRedirecting to \/bin\/systemctl status privoxy.service\r\n\u25cf privoxy.service - Privoxy Web Proxy With Advanced Filtering Capabilities\r\n  Loaded: loaded (\/usr\/lib\/systemd\/system\/privoxy.service; disabled; vendor preset: disabled)\r\n  Active: active (running) since Wed 2020-03-04 17:38:26 CST; 5s ago\r\n Process: 23138 ExecStart=\/usr\/sbin\/privoxy --pidfile \/run\/privoxy.pid --user privoxy \/etc\/privoxy\/config (code=exited, status=0\/SUCCESS)\r\n Main PID: 23139 (privoxy)\r\n  Memory: 872.0K\r\n  CGroup: \/system.slice\/privoxy.service\r\n      \u2514\u250023139 \/usr\/sbin\/privoxy --pidfile \/run\/privoxy.pid --user privox...\r\n \r\nMar 04 17:38:25 localhost.localdomain systemd[1]: Starting Privoxy Web Proxy ...\r\nMar 04 17:38:26 localhost.localdomain systemd[1]: Started Privoxy Web Proxy W...\r\nHint: Some lines were ellipsized, use -l to show in full.\r\n[root@localhost ~]# netstat -anop | grep 8118\r\ntcp    0   0 0.0.0.0:8118      0.0.0.0:*        LISTEN   23139\/privoxy    off (0.00\/0\/0)\r\ntcp    0   0 172.16.1.120:8311    172.16.1.123:28118   ESTABLISHED 15519\/nginx: worker off (0.00\/0\/0)<\/pre>\n

3.HttpClient \u8bbe\u7f6e\u4ee3\u7406<\/p>\n

\r\nHttpPost httpPost = new HttpPost(url);\r\n\/\/\u8bbe\u7f6e\u4ee3\u7406IP\uff0c\u8bbe\u7f6e\u8fde\u63a5\u8d85\u65f6\u65f6\u95f4 \u3001 \u8bbe\u7f6e \u8bf7\u6c42\u8bfb\u53d6\u6570\u636e\u7684\u8d85\u65f6\u65f6\u95f4 \u3001 \u8bbe\u7f6e\u4ececonnect Manager\u83b7\u53d6Connection\u8d85\u65f6\u65f6\u95f4\u3001\r\nHttpHost proxy = new HttpHost(\"172.16.1.120\",8118);\r\nRequestConfig requestConfig = RequestConfig.custom()\r\n  .setProxy(proxy)\r\n  .setConnectTimeout(10000)\r\n  .setSocketTimeout(10000)\r\n  .setConnectionRequestTimeout(3000)\r\n  .build();\r\nhttpPost.setConfig(requestConfig);<\/pre>\n
\u5982\u679c\u662f\u65e0\u6cd5\u4fee\u6539\u7684jar\uff0c\u672c\u5730\u5982\u4f55\u8c03\u8bd5\uff1f<\/strong><\/span><\/div>\n

\u627e\u5230\u76ee\u6807\u6e90\u4ee3\u7801\uff0c\u5728\u9879\u76ee\u4ee3\u7801\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u548c\u76ee\u6807\u4ee3\u7801\u4e00\u6837\u7684package\uff0c\u5e76\u65b0\u5efa\u540c\u540d\u7c7b\u6587\u4ef6\uff0c\u62f7\u8d1d\u76ee\u6807\u7c7b\u4ee3\u7801\u81f3\u65b0\u6587\u4ef6\uff0c\u7136\u540e\u8fdb\u884c\u5bf9\u5e94\u4ee3\u7406\u7684\u8bbe\u7f6e\u3002<\/p>\n

\u539f\u7406\u662f\u4ee3\u7801\u53ea\u52a0\u8f7d\u4e00\u6b21\uff0c\u8c01\u6700\u4f18\u5148\u52a0\u8f7d\u8c01\uff0c\u4ece\u800c\u5b9e\u73b0\u4ee3\u7801\u8986\u76d6\u3002<\/p>\n

\u6ce8\u610f\uff1a\u672c\u5730\u5f00\u53d1\u8c03\u8bd5\u5b8c\u6bd5\u540e\uff0c\u8bf7\u5220\u9664\u8fd9\u4e2a\u8986\u76d6\u6587\u4ef6\u3002<\/p>\n

\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u80cc\u666f\uff1a\u5bf9\u63a5\u7b2c\u4e09\u65b9\u63a5\u53e3\uff0c\u7b2c\u4e09\u65b9\u4e3a\u5b89\u5168\u8003\u8651\uff0c\u9700\u8981\u56fa\u5b9aip\u8bbe\u7f6e\u767d\u540d\u5355\u3002\u516c\u53f8\u5bf9\u5916\u4f7f\u7528\u52a8\u6001ip\u3002 \u529e\u6cd5\uff1a 1. \u8d2d\u4e70\u4e00\u53f0 […]<\/p>\n","protected":false},"author":1482,"featured_media":53213,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-175573","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/175573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=175573"}],"version-history":[{"count":3,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/175573\/revisions"}],"predecessor-version":[{"id":175576,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/175573\/revisions\/175576"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/53213"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=175573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=175573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=175573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}