{"id":116993,"date":"2020-06-12T12:43:26","date_gmt":"2020-06-12T04:43:26","guid":{"rendered":"http:\/\/4563.org\/?p=116993"},"modified":"2020-06-12T12:43:26","modified_gmt":"2020-06-12T04:43:26","slug":"nginx%e7%bd%91%e7%ab%99http%e8%87%aa%e5%8a%a8%e8%b7%b3%e8%bd%achttps%e6%80%8e%e4%b9%88%e5%81%9a","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=116993","title":{"rendered":"nginx\u7f51\u7ad9http\u81ea\u52a8\u8df3\u8f6chttps\u600e\u4e48\u505a"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>amo<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>nginx\u7f51\u7ad9http\u81ea\u52a8\u8df3\u8f6chttps\u600e\u4e48\u505a<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 amo \u4e8e 2020-6-12 10:37 \u7f16\u8f91 <\/p>\n<p> \u5b9d\u5854\u662f\u8fd9\u6837\u5199\u7684 \uff0c\u4f46\u662f\u767e\u5ea6\u8718\u86db\u6293\u53d6\uff0c\u6293\u53d6\u5f02\u5e38\u4fe1\u606f\uff1a&nbsp; &nbsp; &nbsp; &nbsp; socket \u8bfb\u5199\u9519\u8bef\uff0c\u5173\u6389\u5f3a\u5236SSL\u5c31\u6b63\u5e38<\/p>\n<p>  &nbsp; &nbsp; if ($server_port !~ 443){<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;rewrite ^(\/.*)$ https:\/\/$host$1 permanent;<br \/>  &nbsp; &nbsp; }<br \/>  \u8fd8\u6709\u5176\u4ed6\u5199\u6cd5\u6ca1\u6709\uff0c\u5927\u5bb6\u63a8\u8350\u51e0\u4e2a\u6211\u8bd5\u8bd5<\/p>\n<p>  if ($scheme = http ) {<br \/>  return 301 https:\/\/$host$request_uri;<br \/>  }<\/p>\n<p>  if ($server_port = 80 ) {<br \/>  return 301 https:\/\/$host$request_uri;<br \/>  }<\/p>\n<p>  if ($ssl_protocol = &quot;&quot;) { rewrite ^ https:\/\/$server_name$request_uri? permanent; }<br \/>  \u4ee5\u4e0a\u5199\u6cd5\u90fd\u662f\u91cd\u5b9a\u5411\u8fc7\u591a\u3002\u3002\u3002\u3002<\/p>\n<p>  \u597d\u50cf\u53ea\u8981\u5199\u4e86return \u5c31\u662f\u91cd\u5b9a\u5411\u8fc7\u591a\uff0c\uff0c\uff0c\uff0c<br \/>  \u4e0d\u60f3\u5206\u5f00\u5199\u4e86\uff0c\u8c01\u7ed9\u770b\u770b\u600e\u4e48\u5199<\/p>\n<p>  server<br \/>  {<br \/>  &nbsp; &nbsp; listen 80;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; listen 443 ssl http2;<br \/>  server_name www.11111.com 11111.com;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; index index.html index.php index.htm;<br \/>  &nbsp; &nbsp; root \/www\/wwwroot\/www.11111.com;<br \/>  &nbsp; &nbsp; <\/p>\n<p>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #SSL-START SSL\u76f8\u5173\u914d\u7f6e\uff0c\u8bf7\u52ff\u5220\u9664\u6216\u4fee\u6539\u4e0b\u4e00\u884c\u5e26\u6ce8\u91ca\u7684404\u89c4\u5219<br \/>  &nbsp; &nbsp; #error_page 404\/404.html;<br \/>  &nbsp; &nbsp; ssl_certificate&nbsp; &nbsp; \/www\/server\/panel\/vhost\/cert\/www.11111.com\/fullchain.pem;<br \/>  &nbsp; &nbsp; ssl_certificate_key&nbsp; &nbsp; \/www\/server\/panel\/vhost\/cert\/www.11111.com\/privkey.pem;<br \/>  &nbsp; &nbsp; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;<br \/>  &nbsp; &nbsp; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;<br \/>  &nbsp; &nbsp; ssl_prefer_server_ciphers on;<br \/>  &nbsp; &nbsp; ssl_session_cache shared:SSL:10m;<br \/>  &nbsp; &nbsp; ssl_session_timeout 10m;<br \/>  &nbsp; &nbsp; error_page 497https:\/\/$host$request_uri;<\/p>\n<p>  &nbsp; &nbsp; #SSL-END<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #ERROR-PAGE-START\u9519\u8bef\u9875\u914d\u7f6e\uff0c\u53ef\u4ee5\u6ce8\u91ca\u3001\u5220\u9664\u6216\u4fee\u6539<br \/>  &nbsp; &nbsp; #error_page 404 \/404.html;<br \/>  &nbsp; &nbsp; #error_page 502 \/502.html;<br \/>  &nbsp; &nbsp; #ERROR-PAGE-END<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #PHP-INFO-STARTPHP\u5f15\u7528\u914d\u7f6e\uff0c\u53ef\u4ee5\u6ce8\u91ca\u6216\u4fee\u6539<br \/>  &nbsp; &nbsp; include enable-php-53.conf;<br \/>  &nbsp; &nbsp; #PHP-INFO-END<br \/>  &nbsp; &nbsp; <\/p>\n<p>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #\u7981\u6b62\u8bbf\u95ee\u7684\u6587\u4ef6\u6216\u76ee\u5f55<br \/>  &nbsp; &nbsp; location ~ ^\/(.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)<br \/>  &nbsp; &nbsp; {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;return 404;<br \/>  &nbsp; &nbsp; }<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #\u4e00\u952e\u7533\u8bf7SSL\u8bc1\u4e66\u9a8c\u8bc1\u76ee\u5f55\u76f8\u5173\u8bbe\u7f6e<br \/>  &nbsp; &nbsp; location ~ .well-known{<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;allow all;<br \/>  &nbsp; &nbsp; }<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$<br \/>  &nbsp; &nbsp; {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;expires&nbsp; &nbsp;&nbsp; &nbsp;30d;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;error_log off;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;access_log \/dev\/null;<br \/>  &nbsp; &nbsp; }<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; location ~ .*.(js|css)?$<br \/>  &nbsp; &nbsp; {<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;expires&nbsp; &nbsp;&nbsp; &nbsp;12h;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;error_log off;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;access_log \/dev\/null; <br \/>  &nbsp; &nbsp; }<br \/>  &nbsp; &nbsp; access_log\/www\/wwwlogs\/www.11111.com.log;<br \/>  &nbsp; &nbsp; error_log\/www\/wwwlogs\/www.11111.com.error.log;<br \/>  }<br \/>  \u4e0d\u60f3\u5206\u5f00\u5199\u4e86\uff0c\u8c01\u7ed9\u770b\u770b\u600e\u4e48\u5199\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>FeiLai<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u770b\u8fd9\u7bc7\u6587\u7ae0\uff1ahttps:\/\/www.wmsoho.com\/lnmp-nginx-http-to-https-without-www\/\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u5915\u65e5<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 \u5915\u65e5 \u4e8e 2020-6-12 09:53 \u7f16\u8f91 <\/p>\n<p> server {<br \/>  listen 80;<br \/>  server_name xxx.xxx;<br \/>  return 301 https:\/\/$server_name$request_uri;<br \/>  }<\/p>\n<p>  server {<br \/>  listen 443 ssl http2;<br \/>  server_name xxx.xxx;<br \/>  &#8230;&#8230;<br \/>  &#8230;&#8230;<br \/>  }<br \/>  \u6211\u4e00\u822c\u90fd\u662f\u8fd9\u6837\uff0c301\u91cd\u5b9a\u5411yc022t \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u6d41\u6cb3\u65f1\u6811<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tserver {<br \/>  &nbsp; &nbsp; listen 80 default_server;<\/p>\n<p>  &nbsp; &nbsp; server_name _;<\/p>\n<p>  &nbsp; &nbsp; return 301 https:\/\/$host$request_uri;<br \/>  }\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>amo<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tFeiLai \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-6-12 09:50<br \/>  \u770b\u8fd9\u7bc7\u6587\u7ae0\uff1ahttps:\/\/www.wmsoho.com\/lnmp-nginx-http-to-https-without-www\/<\/p>\n<p>  server<br \/>  {<br \/>  &nbsp; &nbsp; listen 80;<br \/>  &nbsp; &nbsp; server_name www.11111.com 11111.com;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; return 301 https:\/\/www.11111.com$request_uri;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; index index.html index.php index.htm;<br \/>  &nbsp; &nbsp; root \/www\/wwwroot\/www.11111.com;<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #SSL-START SSL\u76f8\u5173\u914d\u7f6e\uff0c\u8bf7\u52ff\u5220\u9664\u6216\u4fee\u6539\u4e0b\u4e00\u884c\u5e26\u6ce8\u91ca\u7684404\u89c4\u5219<br \/>  &nbsp; &nbsp; #error_page 404\/404.html;<br \/>  &nbsp; &nbsp; #SSL-END<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #ERROR-PAGE-START\u9519\u8bef\u9875\u914d\u7f6e\uff0c\u53ef\u4ee5\u6ce8\u91ca\u3001\u5220\u9664\u6216\u4fee\u6539<br \/>  &nbsp; &nbsp; #error_page 404 \/404.html;<br \/>  &nbsp; &nbsp; #error_page 502 \/502.html;<br \/>  &nbsp; &nbsp; #ERROR-PAGE-END<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #PHP-INFO-STARTPHP\u5f15\u7528\u914d\u7f6e\uff0c\u53ef\u4ee5\u6ce8\u91ca\u6216\u4fee\u6539<br \/>  &nbsp; &nbsp; include enable-php-53.conf;<br \/>  &nbsp; &nbsp; #PHP-INFO-END<br \/>  &nbsp; &nbsp; <\/p>\n<p>  &nbsp; &nbsp; access_log\/www\/wwwlogs\/www.11111.com.log;<br \/>  &nbsp; &nbsp; error_log\/www\/wwwlogs\/www.11111.com.error.log;<br \/>  }<\/p>\n<p>  server<br \/>  {<br \/>  &nbsp; &nbsp; listen 443 ssl http2;<br \/>  &nbsp; &nbsp; server_name 11111.com;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; return 301 https:\/\/www.11111.com$request_uri;<br \/>  &nbsp; &nbsp; &nbsp; &nbsp; index index.html index.php index.htm;<br \/>  &nbsp; &nbsp; root \/www\/wwwroot\/www.11111.com;<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp;#SSL-START SSL\u76f8\u5173\u914d\u7f6e\uff0c\u8bf7\u52ff\u5220\u9664\u6216\u4fee\u6539\u4e0b\u4e00\u884c\u5e26\u6ce8\u91ca\u7684404\u89c4\u5219<br \/>  &nbsp; &nbsp; #error_page 404\/404.html;<br \/>  &nbsp; &nbsp; ssl_certificate&nbsp; &nbsp; \/www\/server\/panel\/vhost\/cert\/www.11111.com\/fullchain.pem;<br \/>  &nbsp; &nbsp; ssl_certificate_key&nbsp; &nbsp; \/www\/server\/panel\/vhost\/cert\/www.11111.com\/privkey.pem;<br \/>  &nbsp; &nbsp; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;<br \/>  &nbsp; &nbsp; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;<br \/>  &nbsp; &nbsp; ssl_prefer_server_ciphers on;<br \/>  &nbsp; &nbsp; ssl_session_cache shared:SSL:10m;<br \/>  &nbsp; &nbsp; ssl_session_timeout 10m;<br \/>  &nbsp; &nbsp; error_page 497https:\/\/$host$request_uri;<\/p>\n<p>  &nbsp; &nbsp; #SSL-END<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #ERROR-PAGE-START\u9519\u8bef\u9875\u914d\u7f6e\uff0c\u53ef\u4ee5\u6ce8\u91ca\u3001\u5220\u9664\u6216\u4fee\u6539<br \/>  &nbsp; &nbsp; #error_page 404 \/404.html;<br \/>  &nbsp; &nbsp; #error_page 502 \/502.html;<br \/>  &nbsp; &nbsp; #ERROR-PAGE-END<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; #PHP-INFO-STARTPHP\u5f15\u7528\u914d\u7f6e\uff0c\u53ef\u4ee5\u6ce8\u91ca\u6216\u4fee\u6539<br \/>  &nbsp; &nbsp; include enable-php-53.conf;<br \/>  &nbsp; &nbsp; #PHP-INFO-END<br \/>  &nbsp; &nbsp; <\/p>\n<p>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; access_log\/www\/wwwlogs\/https.www.11111.com.log;<br \/>  &nbsp; &nbsp; error_log\/www\/wwwlogs\/https.www.11111.com.error.log;<br \/>  }<\/p>\n<p>  \u6211\u6309\u8fd9\u6837\u5199 \u4e0d\u884c\u7684\uff0c\u76f4\u63a5\u7f51\u9875\u6253\u4e0d\u5f00 \u91cd\u5b9a\u5411\u8fc7\u591a\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>Ticifer<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tif ($ssl_protocol = &quot;&quot;) { return 301 https:\/\/$host$request_uri; }\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>amo<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u4e0d\u884c\u554a \u90fd\u662f\u91cd\u5b9a\u5411\u8fc7\u591a \u597d\u50cf\u4e5f\u6ca1\u5176\u4ed6\u91cd\u5b9a\u5411\u4e86 \u600e\u4e48\u56de\u4e8b\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>cheshirex<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5957CDN\u6ca1\uff1f\u5957\u4e86\u7684\u8bdd\u7528https443\u56de\u6e90\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>amo \u5927\u4f6c\u6709\u8bdd\u8bf4 : nginx&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\/116993"}],"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=116993"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/116993\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=116993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=116993"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=116993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}