{"id":315,"date":"2026-07-08T16:04:27","date_gmt":"2026-07-08T08:04:27","guid":{"rendered":"https:\/\/www.mooloco.com\/?p=315"},"modified":"2026-07-08T17:35:45","modified_gmt":"2026-07-08T09:35:45","slug":"openresty-le-setup","status":"publish","type":"post","link":"https:\/\/www.mooloco.com\/?p=315","title":{"rendered":"openresty-le-setup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u7ed9\u300c\u7f16\u8bd1\u5b89\u88c5\u7684 OpenResty\u300d\u81ea\u52a8\u914d Let&#8217;s Encrypt HTTPS \u7684\u4e00\u4f53\u5316\u811a\u672c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OpenResty \u4e0d\u50cf\u5b98\u65b9 nginx \u90a3\u6837\u6709 certbot \u63d2\u4ef6\u80fd\u81ea\u52a8\u6539\u914d\u7f6e\u3001\u81ea\u52a8\u8df3\u8f6c HTTPS\uff0c \u8fd9\u4e2a\u811a\u672c\u628a\u300c\u5efa webroot \u76ee\u5f55 \u2192 \u63d2\u5165 acme-challenge location \u2192 reload \u2192 certbot webroot \u7b7e\u53d1\u8bc1\u4e66 \u2192 \u628a 80 \u7aef\u53e3\u5757\u62c6\u6210\u8df3\u8f6c + 443 \u7aef\u53e3 SSL \u5757 \u2192 \u518d\u6b21 reload\u300d\u8fd9\u4e00\u6574\u5957\u64cd\u4f5c\u4e32\u6210\u4e00\u6761\u547d\u4ee4\u3002<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-cebdc926-199c-4583-92d3-7e50d2628e40\" href=\"https:\/\/www.mooloco.com\/wp-content\/uploads\/2026\/07\/openresty-le-setup.zip\">\u811a\u672c\u5730\u5740\uff1aopenresty-le-setup<\/a><a href=\"https:\/\/www.mooloco.com\/wp-content\/uploads\/2026\/07\/openresty-le-setup.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-cebdc926-199c-4583-92d3-7e50d2628e40\">\u4e0b\u8f7d<\/a><\/div>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_75 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E5%8A%9F%E8%83%BD\" >\u529f\u80fd<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E5%89%8D%E6%8F%90%E6%9D%A1%E4%BB%B6\" >\u524d\u63d0\u6761\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E7%94%A8%E6%B3%95\" >\u7528\u6cd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\" >\u53c2\u6570\u8bf4\u660e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B\" >\u6267\u884c\u6d41\u7a0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\" >\u6ce8\u610f\u4e8b\u9879<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.mooloco.com\/?p=315\/#%E5%BD%BB%E5%BA%95%E5%88%A0%E9%99%A4%E6%9F%90%E4%B8%AA%E5%9F%9F%E5%90%8D%E7%9A%84%E8%AF%81%E4%B9%A6_%E5%8F%96%E6%B6%88%E7%BB%AD%E6%9C%9F\" >\u5f7b\u5e95\u5220\u9664\u67d0\u4e2a\u57df\u540d\u7684\u8bc1\u4e66 \/ \u53d6\u6d88\u7eed\u671f<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8A%9F%E8%83%BD\"><\/span>\u529f\u80fd<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u81ea\u52a8\u5b9a\u4f4d\u6307\u5b9a\u57df\u540d\u5728 OpenResty \u914d\u7f6e\u91cc\u5bf9\u5e94\u7684\u00a0<code>server{}<\/code>\u00a0\u5757\uff08\u6309\u00a0<code>server_name<\/code>\u00a0\u641c\u7d22\u00a0<code>conf-dir<\/code>\/<code>conf-file<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u81ea\u52a8\u521b\u5efa\u5e76\u6388\u6743 webroot \u76ee\u5f55\uff08<code>\/var\/www\/_letsencrypt<\/code>\u00a0\u9ed8\u8ba4\uff09\uff0c\u4f9b certbot\u00a0<code>--webroot<\/code>\u00a0\u65b9\u5f0f\u9a8c\u8bc1\u4f7f\u7528\u3002<\/li>\n\n\n\n<li>\u81ea\u52a8\u5728\u8be5\u57df\u540d\u7684 80 \u7aef\u53e3\u5757\u91cc\u63d2\u5165\u00a0<code>\/.well-known\/acme-challenge\/<\/code>\u00a0location\uff08\u82e5\u5df2\u5b58\u5728\u5219\u8df3\u8fc7\uff0c\u5e42\u7b49\uff09\u3002<\/li>\n\n\n\n<li>\u82e5\u8bc1\u4e66\u4e0d\u5b58\u5728\uff0c\u81ea\u52a8\u6267\u884c\u00a0<code>certbot certonly --webroot ...<\/code>\u00a0\u7b7e\u53d1\uff08\u5df2\u5b58\u5728\u5219\u8df3\u8fc7\uff0c\u4e0d\u4f1a\u91cd\u590d\u7533\u8bf7\uff09\u3002<\/li>\n\n\n\n<li>\u7528\u00a0<code>--webroot<\/code>\u00a0\u7b7e\u53d1\u540e\uff0c\u8bc1\u4e66\u7684\u7eed\u671f\u65b9\u5f0f\u81ea\u52a8\u5c31\u662f\u00a0<code>webroot<\/code>\uff0c<strong>\u4e0d\u9700\u8981\u505c OpenResty\u3001\u4e0d\u9700\u8981\u989d\u5916 pre\/post hook<\/strong>\uff0c<code>certbot.timer<\/code>\u00a0\u5230\u671f\u81ea\u52a8\u7eed\u671f\u5373\u53ef\u3002<\/li>\n\n\n\n<li>\u81ea\u52a8\u628a\u539f\u6765\u7684 80 \u7aef\u53e3\u53cd\u4ee3\u5757\u62c6\u5206\u6210\u4e24\u5757\uff1a\n<ul class=\"wp-block-list\">\n<li>80 \u7aef\u53e3\uff1a\u4fdd\u7559\u00a0<code>listen<\/code>\/<code>server_name<\/code>\u00a0+ acme-challenge location + 301 \u8df3\u8f6c\u5230 https\u3002<\/li>\n\n\n\n<li>443 \u7aef\u53e3\uff1a\u590d\u5236\u539f\u6709\u5185\u5bb9\uff08\u542b\u53cd\u4ee3 location \u7b49\uff09\uff0c\u8865\u4e0a\u00a0<code>ssl_certificate<\/code>\/<code>ssl_certificate_key<\/code>\u00a0\u7b49\u6307\u4ee4\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u6bcf\u6b21\u5199\u6587\u4ef6\u524d\u90fd\u4f1a\uff1a\u6253\u5370 unified diff\u3001\u975e\u00a0<code>--yes<\/code>\u00a0\u65f6\u4ea4\u4e92\u786e\u8ba4\u3001\u5199\u5165\u524d\u81ea\u52a8\u5907\u4efd\u00a0<code>.bak<\/code>\u3001\u5199\u5165\u540e\u8dd1\u00a0<code>openresty -t<\/code>\u00a0\u6d4b\u8bd5\uff0c\u5931\u8d25\u81ea\u52a8\u56de\u6eda\uff0c\u6210\u529f\u624d reload\u3002<\/li>\n\n\n\n<li>\u652f\u6301\u00a0<code>--dry-run<\/code>\u00a0\u5168\u7a0b\u9884\u89c8\uff0c\u4e0d\u5b9e\u9645\u7b7e\u53d1\u8bc1\u4e66\u3001\u4e0d\u5199\u6587\u4ef6\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%89%8D%E6%8F%90%E6%9D%A1%E4%BB%B6\"><\/span>\u524d\u63d0\u6761\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u57df\u540d\u5df2\u7ecf\u5728 OpenResty \u91cc\u6709\u4e00\u4e2a<strong>\u5355\u7eaf\u7684 80 \u7aef\u53e3 server{} \u5757<\/strong>\uff08\u6bd4\u5982\u5df2\u6709\u7684\u53cd\u4ee3\u914d\u7f6e\uff09\uff0c\u4e14\u8be5 conf \u6587\u4ef6\u91cc\u57df\u540d\u5bf9\u5e94\u7684\u662f<strong>\u9876\u5c42\u3001\u4e0d\u5d4c\u5957<\/strong>\u7684\u00a0<code>server{}<\/code>\u00a0\u5757\u3002<\/li>\n\n\n\n<li>\u57df\u540d\u5df2\u7ecf\u89e3\u6790\u5230\u672c\u673a\u516c\u7f51 IP\uff0c\u4e14\u9632\u706b\u5899\/\u5b89\u5168\u7ec4\u5df2\u653e\u884c 80 \u7aef\u53e3\uff08certbot webroot \u9a8c\u8bc1\u8d70\u660e\u6587 HTTP\uff09\u3002<\/li>\n\n\n\n<li>Python 3\uff08certbot \u672c\u8eab\u4f9d\u8d56\u5b83\uff0c\u4e00\u822c\u5df2\u88c5\u597d\uff09\u3001certbot \u5df2\u5b89\u88c5\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%94%A8%E6%B3%95\"><\/span>\u7528\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># 1. \u5982\u679c\u4e4b\u524d\u7528 --standalone \u7b7e\u53d1\u8fc7\uff0c\u5148\u5220\u6389\u65e7\u8bc1\u4e66\uff08\u4f1a\u4e00\u5e76\u6e05\u6389\u65e7\u7684\u7eed\u671f\u914d\u7f6e\uff09\ncertbot delete --cert-name &lt;domain>\n\n# 2. dry-run \u9884\u89c8\u4f1a\u505a\u7684\u6539\u52a8\uff08\u4e0d\u4f1a\u771f\u6b63\u7b7e\u53d1\u8bc1\u4e66\u3001\u4e0d\u4f1a\u5199\u6587\u4ef6\uff09\nsudo python3 openresty-le-setup.py &lt;domain> \\\n  --email you@example.com \\\n  --conf-file \/path\/to\/domain.conf \\\n  --dry-run\n\n# 3. \u786e\u8ba4\u65e0\u8bef\u540e\u6b63\u5f0f\u6267\u884c\nsudo python3 openresty-le-setup.py &lt;domain> \\\n  --email you@example.com \\\n  --conf-file \/path\/to\/domain.conf\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\"># 1. \u5982\u679c\u4e4b\u524d\u7528 --standalone \u7b7e\u53d1\u8fc7\uff0c\u5148\u5220\u6389\u65e7\u8bc1\u4e66\uff08\u4f1a\u4e00\u5e76\u6e05\u6389\u65e7\u7684\u7eed\u671f\u914d\u7f6e\uff09<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">certbot<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">delete<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--cert-name<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #A3BE8C\">domai<\/span><span style=\"color: #D8DEE9FF\">n<\/span><span style=\"color: #81A1C1\">&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># 2. dry-run \u9884\u89c8\u4f1a\u505a\u7684\u6539\u52a8\uff08\u4e0d\u4f1a\u771f\u6b63\u7b7e\u53d1\u8bc1\u4e66\u3001\u4e0d\u4f1a\u5199\u6587\u4ef6\uff09<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">sudo<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">python3<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">openresty-le-setup.py<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #A3BE8C\">domai<\/span><span style=\"color: #D8DEE9FF\">n<\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #EBCB8B\">\\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #A3BE8C\">--email<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">you@example.com<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #EBCB8B\">\\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #A3BE8C\">--conf-file<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">\/path\/to\/domain.conf<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #EBCB8B\">\\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #A3BE8C\">--dry-run<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\"># 3. \u786e\u8ba4\u65e0\u8bef\u540e\u6b63\u5f0f\u6267\u884c<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">sudo<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">python3<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">openresty-le-setup.py<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #A3BE8C\">domai<\/span><span style=\"color: #D8DEE9FF\">n<\/span><span style=\"color: #81A1C1\">&gt;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #EBCB8B\">\\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #A3BE8C\">--email<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">you@example.com<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #EBCB8B\">\\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">  <\/span><span style=\"color: #A3BE8C\">--conf-file<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">\/path\/to\/domain.conf<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u52a0&nbsp;<code>--conf-file<\/code>&nbsp;\u65f6\uff0c\u811a\u672c\u4f1a\u5728\u4e0b\u5217\u9ed8\u8ba4\u76ee\u5f55\u91cc\u6309&nbsp;<code>server_name<\/code>&nbsp;\u81ea\u52a8\u641c\u7d22\u5339\u914d\u7684 conf \u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-d-8-dee-9-ff-color has-text-color has-875-rem-font-size\"><code>\/etc\/openresty\/conf.d\n\/usr\/local\/openresty\/nginx\/conf\/conf.d\n\/usr\/local\/openresty\/nginx\/conf\/vhost\n\/etc\/nginx\/conf.d\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u53ef\u4ee5\u7528\u591a\u4e2a&nbsp;<code>--conf-dir DIR<\/code>&nbsp;\u6307\u5b9a\u989d\u5916\u641c\u7d22\u8def\u5f84\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\"><\/span>\u53c2\u6570\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u53c2\u6570<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>domain<\/code>\uff08\u5fc5\u586b\uff09<\/td><td>\u8981\u5904\u7406\u7684\u57df\u540d<\/td><\/tr><tr><td><code>--email<\/code><\/td><td>certbot \u6ce8\u518c\u90ae\u7bb1\uff1b\u4e0d\u586b\u5219\u7528&nbsp;<code>--register-unsafely-without-email<\/code><\/td><\/tr><tr><td><code>--webroot<\/code><\/td><td>ACME \u9a8c\u8bc1\u7528\u7684 webroot \u76ee\u5f55\uff0c\u9ed8\u8ba4&nbsp;<code>\/var\/www\/_letsencrypt<\/code><\/td><\/tr><tr><td><code>--conf-dir<\/code><\/td><td>\u641c\u7d22 conf \u6587\u4ef6\u7684\u76ee\u5f55\uff0c\u53ef\u91cd\u590d\u4f20\u591a\u4e2a<\/td><\/tr><tr><td><code>--conf-file<\/code><\/td><td>\u76f4\u63a5\u6307\u5b9a\u8981\u6539\u7684 conf \u6587\u4ef6\uff0c\u8df3\u8fc7\u81ea\u52a8\u641c\u7d22<\/td><\/tr><tr><td><code>--force<\/code><\/td><td>\u5373\u4f7f\u68c0\u6d4b\u5230\u8be5 server \u5757\u5df2\u7ecf\u76d1\u542c 443\uff0c\u4e5f\u7ee7\u7eed\u5904\u7406<\/td><\/tr><tr><td><code>--dry-run<\/code><\/td><td>\u53ea\u6253\u5370\u5c06\u8981\u505a\u7684\u6539\u52a8\u548c\u5c06\u8981\u6267\u884c\u7684 certbot \u547d\u4ee4\uff0c\u4e0d\u5b9e\u9645\u5199\u5165\/\u7b7e\u53d1<\/td><\/tr><tr><td><code>--yes<\/code><\/td><td>\u8df3\u8fc7\u4ea4\u4e92\u786e\u8ba4\uff0c\u76f4\u63a5\u5199\u5165\uff08\u4ecd\u4f1a\u5148\u5907\u4efd\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B\"><\/span>\u6267\u884c\u6d41\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u9636\u6bb5 0<\/strong>\uff1a\u786e\u4fdd\u00a0<code>--webroot<\/code>\u00a0\u76ee\u5f55\u5b58\u5728\uff0c\u5e76\u5c1d\u8bd5\u6839\u636e\u00a0<code>nginx.conf<\/code>\u00a0\u91cc\u7684\u00a0<code>user<\/code>\u00a0\u6307\u4ee4\u81ea\u52a8\u00a0<code>chown<\/code>\u00a0\u7ed9 OpenResty \u8fd0\u884c\u7528\u6237\u3002<\/li>\n\n\n\n<li><strong>\u9636\u6bb5 1<\/strong>\uff1a\u5b9a\u4f4d\u57df\u540d\u5bf9\u5e94\u7684\u00a0<code>server{}<\/code>\u00a0\u5757\uff0c\u82e5\u8fd8\u6ca1\u6709 acme-challenge location \u5c31\u63d2\u5165\uff0c\u5199\u6587\u4ef6\u3001\u6d4b\u8bd5\u3001reload\u3002<\/li>\n\n\n\n<li><strong>\u7b7e\u53d1\u8bc1\u4e66<\/strong>\uff1a\u82e5\u00a0<code>\/etc\/letsencrypt\/live\/&lt;domain><\/code>\u00a0\u4e0d\u5b58\u5728\uff0c\u6267\u884c\u00a0<code>certbot certonly --webroot -w &lt;webroot> -d &lt;domain><\/code>\u3002<\/li>\n\n\n\n<li><strong>\u9636\u6bb5 2<\/strong>\uff1a\u91cd\u65b0\u8bfb\u53d6\u8be5 server \u5757\uff0c\u62c6\u5206\u6210\u300c80 \u8df3\u8f6c\u300d+\u300c443 ssl\u300d\u4e24\u5757\uff0c\u5199\u6587\u4ef6\u3001\u6d4b\u8bd5\u3001reload\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\"><\/span>\u6ce8\u610f\u4e8b\u9879<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u82e5\u8be5 server \u5757\u5df2\u7ecf\u76d1\u542c 443\uff08\u5224\u65ad\u4e3a\u5df2\u914d\u7f6e\u8fc7 HTTPS\uff09\uff0c\u811a\u672c\u9ed8\u8ba4\u76f4\u63a5\u8df3\u8fc7\uff0c\u52a0\u00a0<code>--force<\/code>\u00a0\u53ef\u5f3a\u5236\u91cd\u65b0\u5904\u7406\u3002<\/li>\n\n\n\n<li><code>--dry-run<\/code>\u00a0\u6a21\u5f0f\u4e0b\u9636\u6bb5 2 \u4f1a\u88ab\u6574\u4f53\u8df3\u8fc7\uff08\u56e0\u4e3a\u9700\u8981\u771f\u5b9e\u7b7e\u53d1\u51fa\u6765\u7684\u8bc1\u4e66\u8def\u5f84\uff09\uff0c\u8fd9\u662f\u8bbe\u8ba1\u5982\u6b64\uff0c\u4e0d\u662f bug\u3002<\/li>\n\n\n\n<li>\u811a\u672c\u5047\u8bbe\u300c\u4e00\u4e2a\u57df\u540d = \u4e00\u4e2a\u672a\u5d4c\u5957\u7684\u9876\u5c42\u00a0<code>server{}<\/code>\u00a0\u5757\u300d\u3002\u5982\u679c\u4e00\u4e2a conf \u6587\u4ef6\u91cc\u585e\u4e86\u591a\u4e2a\u00a0<code>server_name<\/code>\u00a0\u5171\u7528\u4e00\u5757\uff0c\u6216\u8005\u7528\u00a0<code>include<\/code>\u00a0\u62c6\u5f97\u5f88\u788e\uff0c\u751f\u6210\u7684 diff \u53ef\u80fd\u4e0d\u5b8c\u5168\u7b26\u5408\u9884\u671f\uff0c<strong>\u52a1\u5fc5\u5148\u8dd1\u00a0<\/strong><code><strong>--dry-run<\/strong><\/code><strong>\u00a0\u4eba\u5de5\u6838\u5bf9<\/strong>\u518d\u6b63\u5f0f\u6267\u884c\u3002<\/li>\n\n\n\n<li>\u82e5\u8fd0\u884c\u65f6\u63d0\u793a&#8221;\u672a\u80fd\u4ece nginx.conf \u68c0\u6d4b\u5230\u8fd0\u884c\u7528\u6237&#8221;\uff0c\u8bf4\u660e\u811a\u672c\u6ca1\u627e\u5230\u4f60\u7f16\u8bd1\u5b89\u88c5\u65f6\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff0c\u9700\u8981\u624b\u52a8\u786e\u8ba4\/<code>chown<\/code>\u00a0<code>webroot<\/code>\u00a0\u76ee\u5f55\u7ed9 OpenResty worker \u7684\u8fd0\u884c\u7528\u6237\uff0c\u5426\u5219 certbot \u9a8c\u8bc1\u53ef\u80fd\u56e0\u6743\u9650\u95ee\u9898\u5931\u8d25\u3002<\/li>\n\n\n\n<li>\u6bcf\u6b21\u5199\u5165\u90fd\u4f1a\u751f\u6210\u540c\u76ee\u5f55\u4e0b\u7684\u00a0<code>xxx.conf.&lt;\u65f6\u95f4\u6233>.bak<\/code>\u00a0\u5907\u4efd\uff0c\u51fa\u95ee\u9898\u53ef\u4ee5\u76f4\u63a5\u62ff\u5b83\u8986\u76d6\u56de\u53bb\u624b\u52a8\u6392\u67e5\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BD%BB%E5%BA%95%E5%88%A0%E9%99%A4%E6%9F%90%E4%B8%AA%E5%9F%9F%E5%90%8D%E7%9A%84%E8%AF%81%E4%B9%A6_%E5%8F%96%E6%B6%88%E7%BB%AD%E6%9C%9F\"><\/span>\u5f7b\u5e95\u5220\u9664\u67d0\u4e2a\u57df\u540d\u7684\u8bc1\u4e66 \/ \u53d6\u6d88\u7eed\u671f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">certbot \u6ca1\u6709\u5355\u72ec\u7684&#8221;\u53d6\u6d88\u7eed\u671f&#8221;\u547d\u4ee4\uff0c\u76f4\u63a5\u5220\u9664\u8bc1\u4e66 lineage \u5373\u53ef\uff0c\u4f1a\u4e00\u5e76\u6e05\u6389\u5bf9\u5e94\u7684\u7eed\u671f\u914d\u7f6e\uff1a<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#d8dee9ff;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>certbot delete --cert-name &lt;domain>\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #88C0D0\">certbot<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">delete<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #A3BE8C\">--cert-name<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">&lt;<\/span><span style=\"color: #A3BE8C\">domai<\/span><span style=\"color: #D8DEE9FF\">n<\/span><span style=\"color: #81A1C1\">&gt;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f1a\u5220\u9664\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/etc\/letsencrypt\/live\/&lt;domain>\/<\/code><\/li>\n\n\n\n<li><code>\/etc\/letsencrypt\/archive\/&lt;domain>\/<\/code><\/li>\n\n\n\n<li><code>\/etc\/letsencrypt\/renewal\/&lt;domain>.conf<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5168\u5c40\u7684&nbsp;<code>certbot.timer<\/code>&nbsp;\u4e0d\u7528\u52a8\uff0c\u5b83\u4ee5\u540e\u4e0d\u4f1a\u518d\u78b0\u8fd9\u4e2a\u5df2\u5220\u9664\u7684\u57df\u540d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u300c\u7f16\u8bd1\u5b89\u88c5\u7684 OpenResty\u300d\u81ea\u52a8\u914d Let&#8217;s Encrypt HTTPS \u7684\u4e00\u4f53\u5316\u811a\u672c\u3002 &#8230; <a title=\"openresty-le-setup\" class=\"read-more\" href=\"https:\/\/www.mooloco.com\/?p=315\" aria-label=\"\u9605\u8bfb openresty-le-setup\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-main_contents"],"_links":{"self":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315"}],"version-history":[{"count":1,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":317,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions\/317"}],"wp:attachment":[{"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooloco.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}