{"id":321,"date":"2022-11-25T15:23:36","date_gmt":"2022-11-25T07:23:36","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/wwwinfo\/321.html"},"modified":"2022-11-25T15:23:36","modified_gmt":"2022-11-25T07:23:36","slug":"nginx-%e5%ae%89%e8%a3%85ssl%e8%af%81%e4%b9%a6-nginx%e9%85%8d%e7%bd%aehttps%e8%af%81%e4%b9%a6%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/wwwinfo\/321.html","title":{"rendered":"Nginx \u5b89\u88c5SSL\u8bc1\u4e66 Nginx\u914d\u7f6ehttps\u8bc1\u4e66\u6559\u7a0b"},"content":{"rendered":"<p><span class=\"wpcom_tag_link\">Nginx<\/span> \u5b89\u88c5SSL\u8bc1\u4e66 <span class=\"wpcom_tag_link\">Nginx\u914d\u7f6ehttps<\/span>\u8bc1\u4e66\u6559\u7a0b<\/p>\n<figure id=\"pid16999\" class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><strong>Nginx \u5b89\u88c5SSL\u8bc1\u4e66<\/strong><br \/>1.\u4e0b\u8f7dSSL\u8bc1\u4e66\u5e76\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7ba1\u7406SSL\u8bc1\u4e66 -&gt; \u8ba2\u5355\u8be6\u7ec6 -&gt; \u4e0b\u8f7dSSL\u8bc1\u4e66 -&gt; \u9009\u62e9 [Nginx] , \u70b9\u51fb[\u4e0b\u8f7dSSL\u8bc1\u4e66]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<pre class=\"wp-block-code\"><code>yourdomain.com.crt     (\u670d\u52a1\u5668\u8bc1\u4e66+CA-BUNDLE)\nyourdomain.com.key     (\u79c1\u94a5\u6587\u4ef6\uff09\u5982\u679c\u4e3a\u7a7a\u8bf7\u5c06\u751f\u6210CSR\u65f6\u4fdd\u5b58\u7684\u79c1\u94a5\u5185\u5bb9\u7c98\u8d34\u5728\u6587\u4ef6\u4e2d<\/code><\/pre>\n<p>2.\u67e5\u627e\u5e76\u7f16\u8f91nginx\u7684\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883nginx\u914d\u7f6e\u6587\u4ef6\u4f4d\u7f6e\u4e0d\u540c. \u4ec5\u5217\u51fa\u51e0\u4e2a\u5e38\u7528\u7684\uff0c\u5177\u4f53\u8bf7\u54a8\u8be2\u670d\u52a1\u5668\u7ba1\u7406\u4eba\u5458<\/p>\n<pre class=\"wp-block-code\"><code>\/etc\/nginx                              #centos \u4f7f\u7528yum\u5b89\u88c5\u4e00\u822c\u5728\u8fd9\u4e2a\u4f4d\u7f6e\n\/etc\/nginx\/sites-available\/example.com  #ubuntu \u7cfb\u7edf\n\/usr\/local\/nginx\/conf\/vhosts            #lnmp<\/code><\/pre>\n<p>3.\u5728\u865a\u62df\u7ad9\u70b9\u4e0a\u914d\u7f6eSSL\u8bc1\u4e66<\/p>\n<p>\u5047\u8bbe\u628a\u8bc1\u4e66\u6587\u4ef6yourdomain.com.crt \u548c yourdomain.com.crt \u4e0a\u4f20\u5230\u670d\u52a1\u5668 \/opt\/<span class=\"wpcom_tag_link\">ssl<\/span>\/ \u76ee\u5f55\u9ed8\u8ba4\u89c4\u5219 HTTP \u8bf7\u6c42\u4f7f\u7528TCP 80\u7aef\u53e3\uff0c\u00a0\u00a0\u6211\u4eec\u73b0\u5728\u53ea\u662f\u914d\u7f6e\u4e00\u4e2anginx\u865a\u62df\u7ad9\u70b9\u4f7f\u7528TCP 443\u7aef\u53e3 \uff08\u4ee5Ubuntu\u4e3a\u4f8b\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff09\u3002<\/p>\n<pre class=\"wp-block-code\"><code>#\u8bf7\u6839\u636e\u81ea\u5df1\u670d\u52a1\u5668\u5b9e\u9645\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u4fee\u6539\nvi \/etc\/nginx\/sites-available\/example.com<\/code><\/pre>\n<p>\u6211\u4eec\u4e0d\u9700\u8981\u5220\u9664\u5df2\u6709\u7684\u7ad9\u70b9\u914d\u7f6e\uff0c\u53ea\u9700\u8981\u589e\u52a0nginx \u914d\u7f6eSSL\u7684\u5fc5\u8981\u53c2\u6570<\/p>\n<pre class=\"wp-block-code\"><code>server {\n        listen 80;\n    #SSL \u914d\u7f6e\u5fc5\u8981\u53c2\u6570\n        listen 443 ssl;\n    #\u7ad9\u70b9\u4e3b\u673a\u540d\n        server_name www.yourdomain.com;\n    #SSL \u914d\u7f6e\u5fc5\u8981\u53c2\u6570\n        ssl_protocols TLSv1.2 TLSv1.1 TLSv1;\n        ssl_certificate \/opt\/ssl\/yourdomain.com.crt;\n        ssl_certificate_key \/opt\/ssl\/yourdomain.com.key;\n        ssl_prefer_server_ciphers on;\n        \n        #\u81ea\u52a8\u8df3\u8f6c\u5230HTTPS (\u53ef\u9009)\n        if ($server_port = 80) {\n                rewrite ^(.*)$ https:\/\/$host$1 permanent;\n        }\n       \n        location \/ {\n                root \/home\/yourdomain\/;\n                index index.php;\n        }\n}<\/code><\/pre>\n<p>\u6ce8\u610f\u4e8b\u9879<\/p>\n<p>ssl_certificate\u00a0\u00a0\/\u00a0\u00a0ssl_certificate_key \u8981\u586b<a href=\"https:\/\/app.applebyme.cn\/shengcheng-122.html\">\u7f51\u9875\u8f6capp\u5de5\u5177\u624b\u673a\u7248<\/a>\u5199\u81ea\u5df1\u4e0a\u4f20\u8bc1\u4e66\u7684\u4f4d\u7f6e<\/p>\n<p>4.\u91cd\u542fnginx\u670d\u52a1<\/p>\n<pre class=\"wp-block-code\"><code>#CentOS6 \u7cfb\u7edf\nservice nginx restart\n#CentOS<a href=\"https:\/\/app.applebyme.cn\/shengcheng-121.html\">\u4e00\u952e\u751f\u6210app\u8f6f\u4ef6<\/a>7 \u7cfb\u7edf \/ Ubuntu\nsystemctl restart nginx  \n#\u65e7\u7684Linux\u7cfb\u7edf\n\/etc\/init.d\/nginx reload\n#Windows nginx\ncd nginx\u5b89\u88c5\u76ee\u5f55\nnginx.exe -s reload<\/code><\/pre>\n<div class=\"entry-copyright\">\n<p>\u7f16\u8f91\uff1a\u5a1c\u5a1c\uff0c\u5982\u82e5\u8f6c\u8f7d\uff0c\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttps:\/\/www.yimenapp.com\/kb-yimen\/4922\/<\/p>\n<p>\u90e8\u5206\u5185\u5bb9\u6765\u81ea\u7f51\u7edc\u6295\u7a3f\uff0c\u5982\u6709\u4fb5\u6743\u8054\u7cfb\u7acb\u5220<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u628a\u8bc1\u4e66\u6587\u4ef6yourdomain.com.crt \u548c yourdomain.com.crt \u4e0a\u4f20\u5230\u670d\u52a1\u5668 \/opt\/ssl\/ \u76ee\u5f55\u9ed8\u8ba4\u89c4\u5219 HTTP \u8bf7\u6c42\u4f7f\u7528TCP 80\u7aef\u53e3\uff0c\u00a0\u00a0\u6211\u4eec\u73b0\u5728\u53ea\u662f\u914d\u7f6e\u4e00\u4e2anginx\u865a\u62df\u7ad9\u70b9\u4f7f\u7528TCP 443\u7aef\u53e3 \uff08\u4ee5Ubuntu\u4e3a\u4f8b\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff09\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[711,712,713,181,696],"class_list":["post-321","post","type-post","status-publish","format-standard","hentry","category-wwwinfo","tag-nginx","tag-nginxssl","tag-nginxhttps","tag-ssl"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=321"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/321\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}