{"id":139519,"date":"2020-07-15T17:22:07","date_gmt":"2020-07-15T09:22:07","guid":{"rendered":"http:\/\/4563.org\/?p=139519"},"modified":"2020-07-15T17:22:07","modified_gmt":"2020-07-15T09:22:07","slug":"nginx-%e5%8f%8c%e9%87%8d%e8%ae%a4%e8%af%81%e8%b7%b3%e8%bd%ac%e9%94%99%e8%af%af","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=139519","title":{"rendered":"nginx \u53cc\u91cd\u8ba4\u8bc1\u8df3\u8f6c\u9519\u8bef"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  nginx \u53cc\u91cd\u8ba4\u8bc1\u8df3\u8f6c\u9519\u8bef               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : anthoy <\/span>  <span><i><\/i> 13<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u5728 nginx \u4e0a\u4f7f\u7528\u4e86\u53cc\u5411\u8ba4\u8bc1\uff0c\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre><code>server {     listen       443 ssl;     server_name  localhost;      ssl_certificate    \/etc\/ssl\/server.crt; # \u914d\u7f6e\u8bc1\u4e66\u4f4d\u7f6e     ssl_certificate_key \/etc\/ssl\/server.key; # \u914d\u7f6e\u79d8\u94a5\u4f4d\u7f6e     ssl_client_certificate \/etc\/ssl\/client.crt; # \u5ba2\u6237\u7aef\u516c\u94a5\u8bc1\u4e66     ssl_verify_client on; # \u53cc\u5411\u8ba4\u8bc1      charset  utf-8;     error_log \/var\/log\/nginx\/nginx_error.log;     access_log \/var\/log\/nginx\/nginx_access.log;     client_max_body_size 75M;     root \/usr\/share\/nginx\/html\/static;      # \u5f00\u542f gzip     gzip on;     # \u542f\u7528 gzip \u538b\u7f29\u7684\u6700\u5c0f\u6587\u4ef6\uff0c\u5c0f\u4e8e\u8bbe\u7f6e\u503c\u7684\u6587\u4ef6\u5c06\u4e0d\u4f1a\u538b\u7f29     gzip_min_length 1k;     # gzip \u538b\u7f29\u7ea7\u522b\uff0c1-10\uff0c\u6570\u5b57\u8d8a\u5927\u538b\u7f29\u7684\u8d8a\u597d\uff0c\u4e5f\u8d8a\u5360\u7528 CPU \u65f6\u95f4     gzip_comp_level 6;     # \u8fdb\u884c\u538b\u7f29\u7684\u6587\u4ef6\u7c7b\u578b\u3002javascript \u6709\u591a\u79cd\u5f62\u5f0f\u3002\u5176\u4e2d\u7684\u503c\u53ef\u4ee5\u5728 mime.types \u6587\u4ef6\u4e2d\u627e\u5230\u3002     gzip_types  application\/x-httpd-php image\/jpeg image\/gif image\/png font\/ttf font\/otf image\/svg+xml text\/plain text\/css application\/javascript application\/json  application\/x-javascript  application\/xml text\/javascript;     # \u662f\u5426\u5728 http header \u4e2d\u6dfb\u52a0 Vary: Accept-Encoding\uff0c\u5efa\u8bae\u5f00\u542f     gzip_vary on;     # \u7981\u7528 IE 6 gzip     gzip_disable \"MSIE [1-6].\";      location \/ {         proxy_pass http:\/\/web:8000\/;     } } <\/code><\/pre>\n<p>\u60f3\u4f7f\u7528\u53cc\u5411\u8ba4\u8bc1\u8bbf\u95ee 443 \u7136\u540e\u8df3\u8f6c\u5230 docker network \u4e2d\u7684 web \u7684 8000 \u7aef\u53e3\u7684<\/p>\n<p>\u4f46\u5728\u4f7f\u7528\u4e2d\u8df3\u8f6c\u4e0d\u6210\u529f\uff0c\u6d4f\u89c8\u5668\u643a\u5e26\u5ba2\u6237\u7aef\u8bc1\u4e66\u8bbf\u95ee\u65f6\u4f1a\u8df3\u8f6c\u5230 https:\/\/\u7f51\u5173\u5730\u5740<\/p>\n<p>\u5982\u679c\u628a<code>proxy_pass http:\/\/web:8000\/;<\/code>\u6362\u4e3a<code>proxy_pass https:\/\/baidu.com;<\/code>\u5374\u53ef\u4ee5\u8df3\u8f6c \u6240\u4ee5\u6211\u8ba4\u4e3a\u662f\u4f7f\u7528\u4e86\u53cc\u5411\u8ba4\u8bc1\u4e4b\u540e\u5bfc\u81f4\u540e\u9762\u7684\u8df3\u8f6c\u5f3a\u5236\u8f6c\u5411 https?<\/p>\n<p>nginx_access.log \u65e5\u5fd7\u5982\u4e0b<\/p>\n<pre><code>- - [22\/Jul\/2020:07:51:57 +0000] \"GET \/ HTTP\/1.1\" 200 84 \"-\" \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/84.0.4147.89 Safari\/537.36\" - - [22\/Jul\/2020:07:51:58 +0000] \"GET \/ HTTP\/1.1\" 200 84 \"-\" \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/84.0.4147.89 Safari\/537.36\" - - [22\/Jul\/2020:07:51:59 +0000] \"GET \/web HTTP\/1.1\" 303 227 \"https:\/\/xxx:443\/\" \"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/84.0.4147.89 Safari\/537.36\" <\/code><\/pre>\n<p>\u6240\u4ee5\u6211\u5f88\u597d\u5947\u662f\u5426\u662f\u53cc\u5411\u8ba4\u8bc1\u7684\u95ee\u9898\uff0c\u662f\u5426\u53cc\u5411\u8ba4\u8bc1\u4e4b\u540e\u540e\u9762\u7684\u53ea\u80fd\u8d70 https\uff0c\u6216\u8005\u8fd8\u662f\u6211\u5728\u54ea\u4e00\u65b9\u9762\u7684\u914d\u7f6e\u6ca1\u6709\u5f04\u597d\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2639041\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : brader <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u8ba4\u4e3a\u662f\u6d4f\u89c8\u5668\u7684\u5b89\u5168\u7b56\u7565\u95ee\u9898\uff0c\u56e0\u4e3a\u767e\u5ea6\u7684\u57df\u540d\u8bc1\u4e66\u662f\u5408\u6cd5\u7684\uff0c\u6240\u4ee5\u8df3\u8fc7\u53bb\u6ca1\u6709\u89e6\u53d1\u5b89\u5168\u9650\u5236\u3002<br \/>\u4f60\u5148\u5c1d\u8bd5\u6392\u9664\u6d4f\u89c8\u5668\u95ee\u9898\uff0c\u4f8b\u5982\uff1a\u4f7f\u7528 curl \u5de5\u5177\u6765\u8bbf\u95ee\u6d4b\u8bd5\uff0c\u5e76\u4f7f\u7528 -k \u9009\u9879\u6765\u5ffd\u7565\u8bc1\u4e66\u5b89\u5168\u9a8c\u8bc1\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2639042\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : anthoy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @brader \u4f7f\u7528 curl \u5982\u4e0b\uff1a<br \/>&#8220;`bash<br \/># \u547d\u4ee4<br \/>curl &#8211;cert .\/client.crt &#8211;key .\/client.key https:\/\/xxx:4443 -k<br \/># \u8fd4\u56de<br \/>&lt;html&gt;&lt;head&gt;&lt;script&gt;window.location = &#8216;\/web&#8217; + location.hash;&lt;\/script&gt;&lt;\/head&gt;&lt;\/html&gt;<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2639043\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : anthoy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @brader \u6211\u7528 curl \u6d4b\u8bd5\u4e86\u76f4\u63a5\u8bf7\u6c42\u67d0\u4e2a\u63a5\u53e3\uff0c\u53ef\u4ee5\u8fd4\u56de html\uff0c\u5e94\u8be5\u662f\u4f60\u8bf4\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u7b56\u7565\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2639044\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : anthoy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5df2\u7ecf\u89e3\u51b3\uff0c\u4e4b\u524d\u4e5f\u9047\u5230\u8fc7\u8fd9\u79cd\u60c5\u51b5\uff0c\u4f46\u8fd9\u6b21\u6ca1\u6709\u8054\u60f3\u8d77\u6765<br \/>\u89e3\u51b3\u529e\u6cd5 https:\/\/www.escapelife.site\/posts\/73685720.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2639045\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : byzf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u63a8\u6d4b\u548c\u53cc\u5411\u8ba4\u8bc1\u6ca1\u6709\u5173\u7cfb, \u4f60 https \u4ee3\u7406\u5230 http \u6240\u4ee5\u9875\u9762\u8ba4\u4e3a\u81ea\u5df1\u662f http, \u6240\u4ee5\u9875\u9762\u4e2d\u7684\u8df3\u8f6c\u4e5f\u4f1a\u7528 http, \u7ed3\u679c\u5c31\u662f\u628a http \u7684\u8bf7\u6c42\u53d1\u5230\u4e86 https \u7684 nginx \u4e0a. curl -k \u4e0d\u4f1a\u8d70\u6b63\u5e38\u7684 https \u9a8c\u8bc1\u6d41\u7a0b.<\/p>\n<p>\u4f60\u5728\u914d\u7f6e\u91cc\u52a0\u4e0a<br \/>proxy_redirect http:\/\/ https:\/\/;<br \/>\u8bd5\u8bd5.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>nginx \u53cc\u91cd\u8ba4\u8bc1\u8df3\u8f6c\u9519\u8bef \u8cc7\u6df1&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\/139519"}],"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=139519"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/139519\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=139519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=139519"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=139519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}