{"id":340912,"date":"2021-02-14T04:28:02","date_gmt":"2021-02-13T20:28:02","guid":{"rendered":"http:\/\/4563.org\/?p=340912"},"modified":"2021-02-14T04:28:02","modified_gmt":"2021-02-13T20:28:02","slug":"nginx-%e6%ad%a3%e5%90%91%e4%bb%a3%e7%90%86%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=340912","title":{"rendered":"nginx \u6b63\u5411\u4ee3\u7406\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  nginx \u6b63\u5411\u4ee3\u7406\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sockball07 <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6839\u636e \u8be5\u6587\u7ae0 \u4f7f\u7528\u4ee5\u4e0b\u914d\u7f6e\u5373\u53ef\u6b63\u5411\u4ee3\u7406<\/p>\n<pre><code>server {     resolver 114.114.114.114;     listen 80;     location \/ {         proxy_pass http:\/\/$host$request_uri;     } }  server {     resolver 114.114.114.114;     listen 443;     location \/ {        proxy_pass https:\/\/$host$request_uri;     } } <\/code><\/pre>\n<p>\u4f7f\u7528\u5373<\/p>\n<pre><code>curl -x http:\/\/[ip]:80 www.baidu.com curl -x http:\/\/[ip]:443 www.reddit.com <\/code><\/pre>\n<p>\u7531\u4e8e\u60f3\u52a0\u5165\u5bc6\u7801\uff0c \u4e8e\u662f\u52a0\u5165 http basic \u9a8c\u8bc1\u914d\u7f6e<\/p>\n<pre><code>server {     ...      auth_basic \"auth_basic\";     auth_basic_user_file \/data\/http_basic_auth.txt;      ... } <\/code><\/pre>\n<p>\u800c\u4f7f\u7528\u53ea\u80fd\u8fd9\u6837<\/p>\n<pre><code>curl -u 'user:pass' -x http:\/\/[ip]:443 www.reddit.com <\/code><\/pre>\n<p>\u95ee\uff1a<\/p>\n<ol>\n<li>\n<p>\u5982\u4e0a\u7684\u914d\u7f6e\uff0c \u662f\u4e0d\u662f\u610f\u5473\u7740 http basic \u9a8c\u8bc1\u7684\u90e8\u5206\u540c\u6837\u4f1a\u8f6c\u53d1\u7ed9\u5c06\u8981\u4ee3\u7406\u7684\u7ad9\u70b9<\/p>\n<\/li>\n<li>\n<p>\u8be5\u914d\u7f6e\u4e0e\u4e00\u822c\u7684 <code>curl -x http:\/\/[user]:[pass]@[ip]:[port] https:\/\/www.reddit.com<\/code> \u6709\u4f55\u4e0d\u540c\uff0cnginx \u662f\u5426\u4e5f\u80fd\u914d\u7f6e\u6210\u8fd9\u6837\uff1f<\/p>\n<\/li>\n<\/ol><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5267358\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : love <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u8bb0\u5f97\u62ff nginx \u505a\u4ee3\u7406\u8f6f\u4ef6\u7528\u662f\u884c\u4e0d\u901a\u7684\uff0c\u5177\u4f53\u54ea\u91cc\u4e0d\u597d\u5fd8\u8bb0\u4e86\uff0c\u53ea\u8bb0\u5f97\u4e00\u5f00\u59cb\u4f3c\u4e4e\u7528\u8d77\u6765\u6ca1\u95ee\u9898\uff0c\u7136\u540e\u9a6c\u4e0a\u5c31\u53d1\u73b0\u89e3\u51b3\u4e0d\u4e86\u7684\u75db\u70b9\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267359\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coolcoffee <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             basic auth \u662f\u4f1a\u5199\u5728 Authorization \u91cc\u9762\u7684\uff0c\u4f60\u8bd5\u4e0b proxy_pass Authorization &#8220;&#8221;\uff0c\u8986\u76d6\u6389\u539f\u6765\u7684\u503c\u8bd5\u8bd5\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267360\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhoudaiyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @love HTTP CONNECT \uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267361\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : love <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zhoudaiyu \u4e5f\u8bb8\u548c\u6253\u5f00 https \u7f51\u7ad9\u6709\u5173\uff0c\u96be\u9053\u662f\u6253\u5f00 http \u91cd\u5b9a\u5411\u5230 https \u7684\u7f51\u5740\u4e0d\u884c\u5417\uff0c\u8bb0\u4e0d\u6e05\u4e86\uff0c\u603b\u4e4b\u6709\u5751\uff0c\u4e0d\u5982\u5c31\u7528\u4e13\u7528\u7684\u4ee3\u7406\u8f6f\u4ef6\u5982 gost \u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267362\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ryd994 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https \u7f51\u7ad9\u4e0d\u80fd\u7528 nginx \u4ee3\u7406\u3002HTTPS \u9700\u8981\u4f7f\u7528 CONNECT\uff0cnginx \u4e0d\u652f\u6301\u8fd9\u4e2a\u3002\u8fd9\u7bc7\u6587\u7ae0\u6839\u672c\u5c31\u662f\u653e\u5c41\u3002HTTPS \u8fde\u8bc1\u4e66\u90fd\u6ca1\u6709\uff0c\u800c\u4e14\u4f60\u4e5f\u4e0d\u53ef\u80fd\u6709\u5bf9\u9762\u7ad9\u70b9\u7684\u79c1\u94a5\u3002\u6ca1\u6709\u79c1\u94a5\uff0c\u4e5f\u4e0d\u690d\u5165 CA\uff0c\u5c31\u7b97\u4e0d\u662f NGINX\uff0c\u4e5f\u4e0d\u53ef\u80fd\u5f97\u77e5 URI \u3002<\/p>\n<p>\u4ee3\u7406\u9a8c\u8bc1\u7684\u4e8b\u60c5\uff0c\u6b63\u89c4\u7684\u4ee3\u7406\u8f6f\u4ef6\u90fd\u6709\u6b63\u5e38\u7684\u89e3\u51b3\u529e\u6cd5\u3002\u4e3a\u4ec0\u4e48\u7528 Nginx \uff1f Squid \u4e0d\u597d\u5417\uff1f<\/p>\n<p>HTTP basic \u9a8c\u8bc1\u5b9e\u9645\u4e0a\u5c31\u662f\u628a\u7528\u6237\u540d\u548c\u5bc6\u7801 base64 \u540e\u52a0\u5230 Authorization header \u91cc\u3002\u6240\u4ee5\u4f60\u8fd9\u6837\u7528\u7684\u8bdd\uff0c\u786e\u5b9e\u662f\u4f1a\u88ab\u4f20\u9012\u5230\u5bf9\u9762\u670d\u52a1\u5668\u7684\u3002\u800c\u4e14\u5728\u5bf9\u9762\u7ad9\u70b9\u672c\u8eab\u5c31\u4f7f\u7528\u9a8c\u8bc1\u7684\u60c5\u51b5\u4e0b\uff0c\u65e0\u6cd5\u4f7f\u7528\u3002<br \/>\u6b63\u89c4\u4ee3\u7406\u9274\u6743\u7528\u7684\u662f Proxy-Authorization header \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267363\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ryd994 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53e6\u5916\uff0cnginx \u73b0\u5728\u652f\u6301 SNI \u4e86\uff0c\u505a\u53cd\u5411\u4ee3\u7406\u8fd8\u53ef\u4ee5\u7528 SNI \u4fe1\u606f\u3002<br \/>\u4f46\u662f\uff0c\u5373\u4f7f\u5982\u6b64\uff0c\u4f60\u4e5f\u6ca1\u6cd5\u628a nginx \u5f53\u4f5c\u6b63\u5411\u4ee3\u7406\u7528\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267364\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : sockball07 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coolcoffee #2 \u90a3\u770b\u6765\u786e\u5b9e\u662f\u8fd9\u4e48\u4e2a\u9053\u7406 \u800c\u4e14\u5982\u679c\u5bf9\u9762\u7ad9\u70b9\u4f7f\u7528\u4e86 Authorization \u5c31\u65e0\u6548\u4e86\uff08 5 \u4e5f\u6709\u63d0\u5230\uff09<\/p>\n<p>@ryd994 #5 \u90a3\u4e3a\u4ec0\u4e48\u6839\u636e\u914d\u7f6e \u4f7f\u7528 443 \u7684\u8bdd HTTPS \u7f51\u7ad9\u4e5f\u80fd\u4ee3\u7406\u8bbf\u95ee\u5462&#8230;                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267365\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ryd994 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @sockball07 \u6211\u6000\u7591\u6839\u672c\u6ca1\u7528\u4e0a\u4ee3\u7406\uff0c\u4f60\u53ef\u4ee5\u627e\u4e2a\u80fd\u663e\u793a\u6765\u6e90 ip \u7684\u7f51\u7ad9\u8bd5\u8bd5\u3002\u6bd4\u5982\uff1a<br \/>curl https:\/\/ipecho.net\/plain                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267366\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : sockball07 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ryd994 #8 \u8bd5\u8fc7\u4e86 \u786e\u5b9e\u7528\u4e0a\u4e86&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5267367\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lax <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4ecd\u7136\u662f\u4e2a\u53cd\u5411\u4ee3\u7406                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>nginx \u6b63\u5411\u4ee3\u7406\u7684\u95ee\u9898 \u8cc7\u6df1\u5927&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/340912"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340912"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/340912\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340912"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}