{"id":33089,"date":"2023-04-15T17:15:51","date_gmt":"2023-07-16T04:20:26","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/"},"modified":"2024-04-29T23:40:12","modified_gmt":"2024-04-29T15:40:12","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/","title":{"rendered":"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4"},"content":{"rendered":"<p>\u7531\u4e8e\u4e0d\u5c0f\u5fc3\u7834\u574f\u4e86\u7f51\u7edc\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u4f5c\u4e3a\u5907\u5fd8\u5f55\uff0c\u6211\u5c06\u8bb0\u5f55\u4ece\u96f6\u5f00\u59cb\u4f7f\u7528\u6811\u8393\u6d3e\u642d\u5efa\u65e0\u5934Nginx\u7f51\u7edc\u670d\u52a1\u5668\u7684\u6b65\u9aa4\u3002\u65e0\u9700\u8131\u4e0b\u88e4\u5b50\uff0c\u4e00\u5207\u90fd\u6ca1\u95ee\u9898\u3002<\/p>\n<h1>\u76ee\u5f55<\/h1>\n<p>\u4e8b\u524d\u51c6\u5907\u7684\u9879\u76ee<br \/>\n1. \u5c06\u64cd\u4f5c\u7cfb\u7edf\u70e7\u5f55\u5230CD\u5361\u4e0a<br \/>\n2. \u542f\u52a8<br \/>\n3. \u901a\u8fc7SSH\u8fde\u63a5<br \/>\n4. \u7528\u6237\u8bbe\u7f6e<br \/>\n5. \u56fa\u5b9aIP\u5730\u5740<br \/>\n6. \u5c06SSH\u66f4\u6539\u4e3a\u516c\u94a5\u8ba4\u8bc1<br \/>\n7. \u8bbe\u7f6eRaspi\u9632\u706b\u5899<br \/>\n8. \u6253\u5f00\u8def\u7531\u5668\u7684\u7aef\u53e3<br \/>\n9. \u4ece\u5916\u90e8\u8fdb\u884cSSH\u8fde\u63a5<br \/>\n10. \u5c06\u57df\u540d\u4e0emyDNS\u76f8\u5173\u8054<br \/>\n11. \u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684web\u670d\u52a1\u5668nginx(nginx-1.22.0)<br \/>\n12. \u53d1\u884cSSL\u8bc1\u4e66(Let&#8217;s Encrypt)\u5e76\u81ea\u52a8\u66f4\u65b0<\/p>\n<div>\u5728\u8fdb\u884c\u6b65\u9aa4\u65f6\uff0c\u8bf7\u6839\u636e\u60a8\u81ea\u5df1\u7684\u73af\u5883\u66f4\u6539\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c\u793a\u4f8b\u3002<\/div>\n<h1>\u63d0\u524d\u51c6\u5907\u7684\u4e1c\u897f<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u672c\u4f53 \u672c\u8a18\u4e8b\u3067\u306fraspberry pi 4 model B 8G(\u4ee5\u4e0braspi)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">type C\u3000\u30b1\u30fc\u30d6\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">AC\u30a2\u30c0\u30d7\u30bf\u30fc 15W\u4ee5\u4e0a(5V,3A)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">microSD\u30ab\u30fc\u30c9<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">microSD\u30ab\u30fc\u30c9\u30ea\u30fc\u30c0\u30fc<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">MobaXterm(\u30bd\u30d5\u30c8)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30eb\u30fc\u30bf\u30fc\u7ba1\u7406\u8005\u6a29\u9650<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30c9\u30e1\u30a4\u30f3<\/ul>\n<div>\u5982\u679c\u4e0d\u77e5\u9053\u9700\u8981\u51c6\u5907\u4ec0\u4e48\u6216\u8005\u60f3\u4e86\u89e3\u63a8\u8350\u7684\u8bdd\uff0c\u8bf7\u4f7f\u7528\u4e9a\u9a6c\u900a\u8d2d\u4e70\u94fe\u63a5\u3002<\/div>\n<h1>\u5c06OS\u70e7\u5f55\u5230CD\u5361\u4e2d\uff08Raspberry Pi OS Debian 11 Bullseye\uff09<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/8-1.png\" alt=\"image.png\" \/><\/div>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30db\u30b9\u30c8\u540d<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">SSH\u3092\u6709\u52b9\u5316<\/ul>\n<\/li>\n<\/ul>\n<p>\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3092\u4f7f\u3046<br \/>\n\u516c\u958b\u9375\u8a8d\u8a3c\u306e\u307f\u3092\u8a31\u53ef\u3059\u308b<\/p>\n<p>pi\u306e\u305f\u3081\u306eauthrized_keys<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3059\u308b\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d<br \/>\n\u30d1\u30b9\u30ef\u30fc\u30c9<\/p>\n<p>Wi-Fi\u3092\u8a2d\u5b9a\u3059\u308b<\/p>\n<p>SSID<br \/>\n\u30d1\u30b9\u30ef\u30fc\u30c9<br \/>\nWfi\u3092\u4f7f\u3046\u56fd<\/p>\n<p>\u30ed\u30b1\u30fc\u30eb\u3092\u8a2d\u5b9a\u3059\u308b<\/p>\n<p>\u30bf\u30a4\u30e0\u30be\u30fc\u30f3<br \/>\n\u30ad\u30fc\u30dc\u30fc\u30c9\u30ec\u30a4\u30a2\u30a6\u30c8<\/p>\n<p>\u5f53\u4f60\u89c9\u5f97\u6307\u793a\u706f\u6709\u95ee\u9898\u65f6\uff0c\u8bf7\u67e5\u770b\u8fd9\u91cc\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>\u542f\u52a8\u3002<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/13-0.png\" alt=\"image.png\" \/><\/div>\n<h3>\u65e0\u6cd5\u8fde\u63a5\u5230laspberrypi.local\u3002<\/h3>\n<p>\u5728\u8fd9\u91cc\u9047\u5230\u7684\u95ee\u9898\u662f\uff0c\u5728Windows10\u7684\u9519\u8bef\u9020\u6210mDNS\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u6709\u65f6\u5019\u5373\u4f7f\u5bf9laspberrypi.local\u8fdb\u884cping\u64cd\u4f5c\u4e5f\u65e0\u6cd5\u89e3\u6790\u540d\u79f0\u3002\u5728\u4e3b\u8981\u73af\u5883\u4e2d\uff0c\u901a\u8fc7\u91cd\u65b0\u542f\u52a8win\u53ef\u4ee5\u6682\u65f6\u89e3\u51b3\uff0c\u4f46\u6839\u672c\u89e3\u51b3\u65b9\u6848\u4f3c\u4e4e\u662f\u7b49\u5f85win\u7684\u66f4\u65b0\u3002\u5982\u679c\u95ee\u9898\u65e0\u6cd5\u89e3\u51b3\uff0c\u65e0\u6cd5\u8fdb\u884cSSH\u8fde\u63a5\uff0c\u6240\u4ee5\u9700\u8981\u4f7f\u7528netscan.exe\u3001\u8def\u7531\u5668\u7ba1\u7406\u754c\u9762\u7b49\u65b9\u6cd5\u6765\u627e\u5230\u6811\u8393\u6d3e\u7684IP\u5730\u5740\u3002\u867d\u7136\u6709\u4e3b\u673a\u540d\u4f1a\u5f88\u65b9\u4fbf\uff0c\u4f46\u53ea\u8981\u77e5\u9053IP\u5730\u5740\uff0c\u8fd9\u6b21\u6211\u4eec\u5c31\u4e0d\u4f1a\u9047\u5230\u95ee\u9898\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>\u901a\u8fc7SSH\u8fdb\u884c\u8fde\u63a5<\/h1>\n<p>\u4e00\u65e6\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7SSH\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u4e3b\u673a\u3002\u8fde\u63a5\u8bbe\u7f6e\u5c06\u4f7f\u7528\u5b89\u88c5\u65f6\u7684\u4fdd\u5b58\u7684\u8bb0\u5fc6\u8fdb\u884c\u53c2\u8003\u3002<br \/>\n\u5bf9\u4e8eMobaXterm\uff0c\u53ef\u4ee5\u5728\u201c\u4f1a\u8bdd\u8bbe\u7f6e\u201d\u9009\u9879\u4e2d\u9009\u62e9SSH\u5e76\u8f93\u5165\u76f8\u5e94\u8bbe\u7f6e\u9879\u3002<br \/>\n\u2605 \u5728\u201c\u4e66\u7b7e\u8bbe\u7f6e\u201d\u9009\u9879\u5361\u4e2d\uff0c\u5c06\u4f1a\u8bdd\u540d\u79f0\u5907\u6ce8\u4e3a\u4f7f\u7528\u5bc6\u7801\u8ba4\u8bc1\u5c06\u4f1a\u5728\u4e4b\u540e\u66f4\u52a0\u4fbf\u5229\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/19-1.png\" alt=\"image.png\" \/><\/div>\n<pre class=\"post-pre\"><code>pi@raspberrypi:~ $ lsb_release -a\r\nNo LSB modules are available.\r\nDistributor ID: Debian\r\nDescription:    Debian GNU\/Linux 11 (bullseye)\r\nRelease:        11\r\nCodename:       bullseye\r\n<\/code><\/pre>\n<h1>4. \u7528\u6237\u914d\u7f6e<\/h1>\n<h3>\u2460. \u4e3aroot\u7528\u6237\u8bbe\u7f6e\u5bc6\u7801<\/h3>\n<pre class=\"post-pre\"><code>sudo passwd root\r\n<\/code><\/pre>\n<h3>\u2461. \u6dfb\u52a0\u5e38\u7528\u7528\u6237\uff08\u4ee5\u4e0b\u6dfb\u52a0&#8221;\u7528\u6237\u540d&#8221;\uff09<\/h3>\n<pre class=\"post-pre\"><code>sudo adduser username\r\n<\/code><\/pre>\n<h3>3. \u78ba\u8a8d pi \u7528\u6237\u7684\u6743\u9650<\/h3>\n<pre class=\"post-pre\"><code>pi@raspberrypi:~ $ groups pi\r\npi : pi adm dialout cdrom sudo audio video plugdev games users input netdev pi spi gpio\r\n<\/code><\/pre>\n<h3>\u7ed9\u65b0\u6dfb\u52a0\u7684\u7528\u6237\u590d\u5236\u6743\u9650\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo usermod -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input,spi,gpio username\r\n<\/code><\/pre>\n<h3>\u786e\u8ba4\u590d\u5236\u7684\u6743\u9650<\/h3>\n<pre class=\"post-pre\"><code>pi@raspberrypi:~ $ groups username\r\nusername : username adm dialout cdrom sudo audio video plugdev games users input netdev pi spi gpio\r\n<\/code><\/pre>\n<h3>\u4ecepi\u7528\u6237\u590d\u5236\u6587\u4ef6\u5939<\/h3>\n<pre class=\"post-pre\"><code>sudo cp -r \/home\/pi\/* \/home\/username\r\n<\/code><\/pre>\n<h3>\u2467\u6811\u8393\u6d3e\u91cd\u65b0\u542f\u52a8<\/h3>\n<pre class=\"post-pre\"><code>sudo reboot\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7531\u4e8eSSH\u8fde\u63a5\u4e2d\u65ad\uff0c\u5728\u91cd\u65b0\u8fde\u63a5\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5728MobaXterm\u7684SSH\u8bbe\u7f6e\u4e2d\u5c06\u7528\u6237\u4ecepi\u66f4\u6539\u4e3ausername\uff0c\u7136\u540e\u91cd\u65b0\u8fde\u63a5\u3002<\/p>\n<h3>\u53d6\u6d88\u81ea\u52d5\u767b\u9304\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo raspi-config\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/39-2.png\" alt=\"image.png\" \/><\/div>\n<h3>\u5220\u96649\u53f7Pi\u7528\u6237<\/h3>\n<pre class=\"post-pre\"><code>sudo userdel -r pi\r\n<\/code><\/pre>\n<h3>\u6211\u9700\u8981\u786e\u8ba4\u662f\u5426\u5df2\u7ecf\u5220\u9664\u4e86\u3002<\/h3>\n<pre class=\"post-pre\"><code>username@raspberrypi:~ $ id -a pi\r\nid: \u2018pi\u2019: no such user\r\n<\/code><\/pre>\n<p>\u8bf7\u53c2\u9605\u4e0b\u9762\u7684\u6587\u7ae0\u4ee5\u83b7\u53d61\u81f310\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<blockquote><p>&#8220;\u8d2d\u4e70\u540e\u9996\u5148\u843d\u5b9e\uff01\u6811\u8393\u6d3e\u7684\u5b89\u5168\u63aa\u65bd &#8211; \u64cd\u4f5c\u6b65\u9aa4&#8221; &#8211; Qiita<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<h1>5. \u56fa\u5b9aIP\u5730\u5740<\/h1>\n<h3>\u5c06id\u5206\u914d\u7ed9Wi-Fi\u7684\u8bbe\u7f6e\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo nano \/etc\/wpa_supplicant\/wpa_supplicant.conf\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5728\u5b89\u88c5\u65f6\u8fdb\u884c\u4e86WiFi\u8fde\u63a5\u8bbe\u7f6e\uff0c\u5219\u5728\u4e0b\u9762\u7684\u8bbe\u7f6e\u4e2d\u5df2\u7ecf\u8bb0\u5f55\u4e86priority\u548cid_str\uff0c\u8bf7\u5728{}\u5185\u8ffd\u52a0\u5b83\u4eec\u3002priority\u662f\u4f18\u5148\u7ea7\uff0c\u5982\u679c\u6ca1\u6709\u5176\u4ed6\u7f51\u7edc\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a1\u3002id_str\u53ef\u4ee5\u5728\u6807\u7b7e\u4e2d\u4f7f\u7528\u4ee5\u56fa\u5b9aIP\u5730\u5740\u3002\u8bf7\u5728\u53cc\u5f15\u53f7\u4e2d\u81ea\u7531\u8bbe\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>update_config=1\r\nnetwork={\r\n        ssid=\"Wifi5G\"\r\n        psk=2aee2d9814471e7ba806f59f509393d329f2e66096214acd0b23cb7b0195b5\r\n        priority=1\r\n        id_str=\"Home\"\r\n}\r\n<\/code><\/pre>\n<p>\u987a\u4fbf\u63d0\u4e00\u53e5\uff0c\u5982\u679c\u4ee5\u7c7b\u4f3c\u7684\u683c\u5f0f\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u63cf\u8ff0\uff0c\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u5176\u4ed6wifi\u3002\u5982\u679c\u6709\u591a\u4e2a\u7f51\u7edc\u8bbe\u7f6e\uff0c\u5c06\u6309\u7167\u8f83\u4f4e\u4f18\u5148\u7ea7\u7684\u987a\u5e8f\u8fdb\u884c\u4f18\u5148\u8fde\u63a5\u3002<\/p>\n<h3>\u8bbe\u7f6e\u56fa\u5b9aIP<\/h3>\n<pre class=\"post-pre\"><code>sudo nano \/etc\/dhcpcd.conf\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u8bb0\u5f55\u4e86\u8fde\u63a5\u7f51\u7edc\u7684IP\u8bbe\u7f6e\u3002\u867d\u7136\u6709\u5f88\u591a\u6ce8\u91ca\u5199\u4e86\u4e00\u4e9b\u5185\u5bb9\uff0c\u4f46\u662f\u6211\u4f1a\u5728&#8221;# Example static IP configuration:&#8221;\u6ce8\u91ca\u7684\u4e0b\u65b9\u9644\u52a0\u4ee5\u4e0b\u8bbe\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code># static IP configuration:\r\n\r\ninterface wlan0\r\niface Home inet static\r\nstatic ip_address=XXX.XXX.XXX.YYY\/24\r\nstatic routers=XXX.XXX.XXX.Z\r\nstatic domain_name_servers=XXX.XXX.XXX.Z\r\n<\/code><\/pre>\n<p>\u5c06\u4e0a\u8ff0\u5185\u5bb9\u8fdb\u884c\u4e2d\u6587\u672c\u5730\u5316\u7ffb\u8bd1, \u53ea\u9700\u8981\u4e00\u4e2a\u9009\u9879\uff1a<\/p>\n<p>\u5982\u679c\u5728Wi-Fi\u8bbe\u7f6e\u65f6\uff0ciface Home inet static\u90e8\u5206\u662fid_str\u7684\u5185\u5bb9\u3002<br \/>\n\u5982\u679c\u6709\u5176\u4ed6\u7f51\u7edc\uff0c\u5219\u53ef\u4ee5\u5728\u5176\u4e0b\u9762\u6dfb\u52a0iface example \uff5e\u4ee5\u53ca\u4e4b\u540e\u7684\u5185\u5bb9\u6765\u5355\u72ec\u8bbe\u7f6eWi-Fi\u3002<br \/>\n\u4f5c\u4e3a\u64cd\u4f5c\u6d4b\u8bd5\uff0c\u53ef\u4ee5\u4f7f\u7528curl\u547d\u4ee4\u6765\u786e\u8ba4\u662f\u5426\u80fd\u591f\u8bbf\u95ee\u4e92\u8054\u7f51\u3002<\/p>\n<pre class=\"post-pre\"><code>username@raspberrypi:~ $ curl https:\/\/example.com\r\n&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n~~~~~~\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<p>\u8bf7\u53c2\u9605\u4ee5\u4e0b\u9875\u9762\uff0c\u4e86\u89e3\u6709\u5173IP\u56fa\u5b9a\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<blockquote><p>\u5728\u6811\u8393\u6d3e\u4e0a\u8fdb\u884c\u591a\u4e2a\u7f51\u7edc\u8bbe\u7f6e &#8211; Qiita<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<h1>\u5c06SSH\u66f4\u6539\u4e3a\u516c\u94a5\u8ba4\u8bc1\u3002<\/h1>\n<h3>\u5728Win\u4e2d\u751f\u6210\u516c\u94a5\u548c\u79c1\u94a5\u3002<\/h3>\n<p>\u5728cmd\u4e2d\u8f93\u5165\u547d\u4ee4\u5e76\u6267\u884c<\/p>\n<pre class=\"post-pre\"><code>ssh-keygen -t rsa -b 4096 -C \"email@example.com\"\r\n<\/code><\/pre>\n<p>\u88ab\u95ee\u53ca\u6587\u4ef6\u751f\u6210\u4f4d\u7f6e\u548c\u8bbf\u95ee\u5bc6\u7801\uff0c\u8bf7\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<h3>\u5c06id_rsa.pub\u4ecewin\u4f20\u8f93\u5230Raspi\u3002<\/h3>\n<p>\u5728Raspi\u4e0a\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\/home\/username\/\u7684.ssh\u6587\u4ef6\u5939\u3002<br \/>\n\u8bf7\u6ce8\u610f\uff0c\u907f\u514d\u4f7f\u7528sudo\u6743\u9650\u521b\u5efa\u6b64\u6587\u4ef6\u5939\uff0c\u4ee5\u514d\u51fa\u73b0\u95ee\u9898\u3002<\/p>\n<pre class=\"post-pre\"><code>mkdir ~\/.ssh\r\n<\/code><\/pre>\n<p>\u901a\u8fc7MobaXterm\u7684\u5bfc\u822a\u7a97\u53e3\u7b49\uff0c\u5c06\u751f\u6210\u7684id_rsa.pub\u4f20\u8f93\u5230\/home\/username\/.ssh\u76ee\u5f55\u4e0b\u3002<\/p>\n<h3>\u5c06id_rsa.pub\u6587\u4ef6\u7684\u5185\u5bb9\u6dfb\u52a0\u5230authorized_keys\u4e2d\u3002<\/h3>\n<pre class=\"post-pre\"><code>cd ~\/.ssh\/\r\ncat id_rsa.pub &gt;&gt; authorized_keys\r\n<\/code><\/pre>\n<h3>\u4fee\u6539\u6743\u9650 (Modify permissions)<\/h3>\n<pre class=\"post-pre\"><code>chmod 600 authorized_keys\r\nchmod 700 ~\/.ssh\r\n<\/code><\/pre>\n<h3>\u5220\u9664\u8f6c\u53d1\u7684\u516c\u94a5\u3002<\/h3>\n<pre class=\"post-pre\"><code>rm -vi ~\/.ssh\/id_rsa.pub\r\n<\/code><\/pre>\n<h3>\u7528\u516c\u94a5\u8fdb\u884cSSH\u8fde\u63a5\u7684\u786e\u8ba4\u3002<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/78-0.png\" alt=\"image.png\" \/><\/div>\n<h3>\u7f16\u8f91ssh\u8ba4\u8bc1\u8bbe\u7f6e\uff0c\u5982\u5bc6\u7801\u8ba4\u8bc1\u7b49\u3002<\/h3>\n<p>\u5728\u9a8c\u8bc1\u516c\u94a5\u8fde\u63a5\u5b8c\u6210\u4e4b\u524d\uff0c\u8bf7\u4e0d\u8981\u65ad\u5f00\u5f53\u524d\u7684SSH\u4f1a\u8bdd\u3002\u5728\u6700\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u5b89\u88c5\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo nano \/etc\/ssh\/sshd_config\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u4e0b\u5217\u9879\u76ee\u88ab\u6ce8\u91ca\u6389\uff0c\u9700\u8981\u8fdb\u884c\u4fee\u6b63\u6216\u6dfb\u52a0\u3002<\/p>\n<pre class=\"post-pre\"><code>\/etc\/ssh\/sshd_config\r\n\r\nPermitRootLogin no\r\nPasswordAuthentication no\r\nPermitEmptyPasswords no\r\n<\/code><\/pre>\n<p>\u91cd\u65b0\u542f\u52a8SSH\u670d\u52a1<\/p>\n<pre class=\"post-pre\"><code>sudo \/etc\/init.d\/ssh restart\r\n<\/code><\/pre>\n<h3>\u8bf7\u786e\u8ba4\u53ea\u80fd\u4f7f\u7528\u516c\u5f00\u5bc6\u94a5\u8bbf\u95ee<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/87-0.png\" alt=\"image.png\" \/><\/div>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6211\u53ef\u4ee5\u4ece\u672c\u5730\u7684WinPC\u4f7f\u7528\u516c\u94a5\u8fdb\u884cSSH\u8fde\u63a5\u5230Raspi\u3002\u5176\u4ed6\u4f1a\u8bdd\u8bbe\u7f6e\u53ef\u4ee5\u5220\u9664\u3002<\/p>\n<p>\u8bf7\u67e5\u9605\u4e0b\u6587\u4ee5\u83b7\u53d6\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<blockquote><p>\u8d2d\u4e70\u540e\u9996\u5148\u8fdb\u884c\u5b9e\u65bd\uff01\u5c06Raspberry Pi\u7684\u5b89\u5168\u63aa\u65bd\u6539\u4e3aSSH\u516c\u94a5\u9a8c\u8bc1- Qiita<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<h1>7. \u8bbe\u7f6e\u6811\u8393\u6d3e\u7684\u9632\u706b\u5899ufw<\/h1>\n<h3>\u2460 \u8981\u66f4\u65b0apt<\/h3>\n<pre class=\"post-pre\"><code>sudo apt update &amp;&amp; sudo apt upgrade\r\n<\/code><\/pre>\n<h3>\u5b89\u88c5 UFW<\/h3>\n<pre class=\"post-pre\"><code>sudo apt install ufw\r\n<\/code><\/pre>\n<h3>\u62d2\u7edd\u6240\u6709\u7684\u7aef\u53e3\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo ufw default deny\r\n<\/code><\/pre>\n<h3>\u5f00\u653eSSH\u7aef\u53e322\uff0cHTTP\u7aef\u53e380\u548cHTTPS\u7aef\u53e3443\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo ufw allow 22\r\nsudo ufw allow 80\r\nsudo ufw allow 443\r\n<\/code><\/pre>\n<h3>\u53ea\u4fdd\u7559IPv4<\/h3>\n<pre class=\"post-pre\"><code>sudo nano \/etc\/default\/ufw\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code># \/etc\/default\/ufw\r\n\r\nIPV6=no\r\n<\/code><\/pre>\n<h3>\u542f\u52a8ufw<\/h3>\n<pre class=\"post-pre\"><code>sudo ufw enable\r\n<\/code><\/pre>\n<h3>\u786e\u8ba4ufw\u7684\u72b6\u6001<\/h3>\n<pre class=\"post-pre\"><code>username@raspberrypi:~ $ sudo ufw status\r\nStatus: active\r\n\r\nTo                         Action      From\r\n--                         ------      ----\r\n22                         ALLOW       Anywhere\r\n80                         ALLOW       Anywhere\r\n443                        ALLOW       Anywhere\r\n<\/code><\/pre>\n<p>\u5982\u679c\u60f3\u8981\u6dfb\u52a0\u5176\u4ed6\u7aef\u53e3\uff0c\u53ef\u4ee5\u5728\u7b2c\u56db\u6b65\u4e2d\u6307\u5b9a\u53e6\u4e00\u4e2a\u7aef\u53e3\u3002<br \/>\n\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u8bf7\u53c2\u8003\u4e0b\u9762\u5185\u5bb9\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>8. \u4e3a\u4e86\u4f7f\u7528SSH\u800c\u6253\u5f00\u8def\u7531\u5668\u7684\u7aef\u53e3<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/111-1.png\" alt=\"image.png\" \/><\/div>\n<p>\u4e00\u65e6\u8fdb\u884c\u7aef\u53e3\u5f00\u653e\u8bbe\u7f6e\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u7f51\u7ad9\u786e\u8ba4\u7aef\u53e3\u662f\u5426\u5df2\u7ecf\u5bf9\u5916\u5f00\u653e\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>9. \u5916\u90e8\u8fdb\u884cSSH\u8fde\u63a5\u3002<\/h1>\n<p>&nbsp;<\/p>\n<p>\u901a\u8fc7\u67e5\u770b\u548c\u8bbe\u7f6e\u5177\u6709WAN\u4fa7IP\u5730\u5740\u7684\u7aef\u53e3\uff0c\u5728\u5916\u90e8\u7f51\u7edc\uff08\u4f8b\u5982\u201c\u5171\u4eab\u8fde\u63a5\u201d\uff09\u4e0a\u8fde\u63a5\u4ee5\u5c066.SSH\u66f4\u6539\u4e3a\u516c\u94a5\u9a8c\u8bc1\u7684\u201c6.\u4f7f\u7528\u516c\u94a5\u786e\u8ba4SSH\u8fde\u63a5\u201d\u7684\u65b9\u5f0f\u3002<\/p>\n<h1>10. \u57df\u540d\u5173\u8054\uff08myDNS\uff09<\/h1>\n<h3>\u81ea\u52a8\u5411myDNS.jp\u901a\u77e5IP<\/h3>\n<p>\u6700\u597d\u7684\u60c5\u51b5\u662f\uff0c\u6211\u4f1a\u4f7f\u7528wget\u547d\u4ee4\u8fdb\u884c\u786e\u8ba4\uff0c\u4f46\u4e3a\u4e86\u7b80\u5316\u6b65\u9aa4\uff0c\u6211\u4f1a\u76f4\u63a5\u5c06\u6d4b\u8bd5\u5199\u5165crontab\u3002<\/p>\n<pre class=\"post-pre\"><code>crontab -e\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>*\/3 * * * * wget -q -O \/dev\/null http:\/\/masterID:Password@ipv4.mydns.jp\/login.html\r\n<\/code><\/pre>\n<p>\u6bcf3\u5206\u949f\u53d1\u9001\u4e00\u6b21IP\u901a\u77e5\uff0c\u8bf7\u5c06masterID\u548cPassword\u66ff\u6362\u4e3a\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u53d1\u9001\u7684myDNS.jp\u767b\u5f55\u4fe1\u606f\u3002<\/p>\n<pre class=\"post-pre\"><code>no crontab for napspans - using an empty one\r\ncrontab: installing new crontab\r\n<\/code><\/pre>\n<h3>\u786e\u8ba4IP\u5730\u5740\u66f4\u65b0<\/h3>\n<p>\u4eceMyDNS\u7684LogInfo\u4e2d\u786e\u8ba4IP\u5730\u5740\u662f\u5426\u5df2\u66f4\u65b0\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/126-0.png\" alt=\"image.png\" \/><\/div>\n<h3>\u786e\u8ba4SSH\u8fde\u63a5<\/h3>\n<p>\u66f4\u6539\u901a\u8fc7SSH\u8fde\u63a5\u7684\u4e3b\u673a\u4e3a\u5728myDNS\u4e0a\u6ce8\u518c\u7684\u57df\u540d\uff0c\u5e76\u4ece\u5916\u90e8\u7f51\u7edc\u8bbf\u95ee\u4ee5\u9a8c\u8bc1\u662f\u5426\u53ef\u4ee5\u8fde\u63a5\u3002<\/p>\n<p>\u53c2\u8003\u6587\u732e\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>11. \u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684nginx web\u670d\u52a1\u5668 (nginx-1.22.0)<\/h1>\n<h3>\u5b89\u88c5\u4f9d\u8d56\u5305\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring\r\n<\/code><\/pre>\n<h3>\u83b7\u53d6\u548c\u5bfc\u5165nginx\u7b7e\u540d\u5bc6\u94a5\u3002<\/h3>\n<pre class=\"post-pre\"><code>curl https:\/\/nginx.org\/keys\/nginx_signing.key | gpg --dearmor | sudo tee \/usr\/share\/keyrings\/nginx-archive-keyring.gpg &gt;\/dev\/null\r\n<\/code><\/pre>\n<h3>\u8bf7\u786e\u8ba4\u94a5\u5319\u662f\u5426\u6b63\u786e\u3002<\/h3>\n<pre class=\"post-pre\"><code>gpg --dry-run --quiet --import --import-options import-show \/usr\/share\/keyrings\/nginx-archive-keyring.gpg\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>\u51fa\u529b\u5185\u5bb9\r\npub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]\r\n      573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62\r\nuid                      nginx signing key &lt;signing-key@nginx.com&gt;\r\n<\/code><\/pre>\n<p>\u9152\u9986\u7684\u6307\u7eb9\u662f573BFD6B3D8FBC641079A6ABF5BD827BD9BF62\u3002<\/p>\n<h3>\u6dfb\u52a0apt\u4ed3\u5e93\u4ee5\u5b89\u88c5\u7a33\u5b9a\u7248\u672c\u7684nginx\u3002<\/h3>\n<pre class=\"post-pre\"><code>username@raspberrypi:~ $ echo \"deb [signed-by=\/usr\/share\/keyrings\/nginx-archive-keyring.gpg] http:\/\/nginx.org\/packages\/debian `lsb_release -cs` nginx\" | sudo tee \/etc\/apt\/sources.list.d\/nginx.list\r\ndeb [signed-by=\/usr\/share\/keyrings\/nginx-archive-keyring.gpg] http:\/\/nginx.org\/packages\/debian bullseye nginx\r\n<\/code><\/pre>\n<p>nginx\u5b98\u65b9\u8f6f\u4ef6\u6e90\u7684\u4f18\u5148\u7ea7<\/p>\n<pre class=\"post-pre\"><code>username@raspberrypi:~ $ echo -e \"Package: *\\nPin: origin nginx.org\\nPin: release o=nginx\\nPin-Priority: 900\\n\" | sudo tee \/etc\/apt\/preferences.d\/99nginx\r\nPackage: *\r\nPin: origin nginx.org\r\nPin: release o=nginx\r\nPin-Priority: 900\r\n<\/code><\/pre>\n<h3>\u5b89\u88c5nginx<\/h3>\n<pre class=\"post-pre\"><code>sudo apt update\r\nsudo apt install nginx\r\n<\/code><\/pre>\n<h3>\u786e\u8ba4nginx\u7248\u672c<\/h3>\n<pre class=\"post-pre\"><code>username@raspberrypi:~ $ nginx -version\r\nnginx version: nginx\/1.22.0\r\n<\/code><\/pre>\n<h3>\u53ea\u9700\u8981\u4e00\u4e2a\u9009\u9879\uff1a\u66f4\u65b0nginx\u914d\u7f6e\u6587\u4ef6\u3002<\/h3>\n<pre class=\"post-pre\"><code>sudo nano \/etc\/nginx\/conf.d\/default.conf\r\n<\/code><\/pre>\n<p>\u5c06\u9ed8\u8ba4\u8bbe\u7f6e\u7684server_name\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<pre class=\"post-pre\"><code># \/etc\/nginx\/conf.d\/default.conf\r\n\r\nserver {\r\n    listen       80;\r\n    server_name  example.com;\r\n\r\n    #access_log  \/var\/log\/nginx\/host.access.log  main;\r\n\r\n    location \/ {\r\n        root   \/usr\/share\/nginx\/html;\r\n        index  index.html index.htm;\r\n    }\r\n\r\n<\/code><\/pre>\n<p>\u8986\u76d6\u5e76\u91cd\u542f\u670d\u52a1<\/p>\n<pre class=\"post-pre\"><code>sudo service nginx restart\r\n<\/code><\/pre>\n<h3>\u8fdb\u884c\u7f51\u7edc\u8fde\u63a5\u6d4b\u8bd5<\/h3>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/155-0.png\" alt=\"image.png\" \/><\/div>\n<p>\u53c2\u8003\u6587\u732e\uff08nginx\u5b98\u65b9\u6587\u6863\uff09<\/p>\n<p>&nbsp;<\/p>\n<h1>12. SSL\u8bc1\u4e66\u7684\u53d1\u5e03\uff08Let&#8217;s Encrypt\uff09\u548c\u81ea\u52a8\u66f4\u65b0<\/h1>\n<p>\u5b89\u88c5CertBot\uff08Let&#8217;s Encrypt\u7684\u5ba2\u6237\u7aef\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo apt install certbot python3-certbot-nginx\r\n<\/code><\/pre>\n<p>\u83b7\u5f97\u8bc1\u4e66<\/p>\n<pre class=\"post-pre\"><code>sudo certbot --nginx -d example.com -d www.example.com\r\n<\/code><\/pre>\n<p>\u6267\u884c\u540e\uff0c\u4f1a\u6709\u51e0\u4e2a\u95ee\u9898\u9700\u8981\u56de\u7b54\u4ee5\u521b\u5efa\u8d26\u6237\u3002<br \/>\n\u5728\u8fd9\u4e2a\u90ae\u7bb1\u4e0a\uff0c\u5c06\u4f1a\u6536\u5230\u901a\u77e5\u8bc1\u4e66\u5373\u5c06\u8fc7\u671f\u3002\u540c\u65f6\uff0c\u7b2c\u4e09\u4e2a\u95ee\u9898\u662f\u5173\u4e8e\u8bb8\u53ef\u5e7f\u544a\u90ae\u4ef6\u7684\u540c\u610f\uff0c\u8bf7\u6ce8\u610f\u3002<\/p>\n<pre class=\"post-pre\"><code>napspans@raspberrypi:~ $ sudo certbot --nginx -d napspans.space -d www.napspans.space\r\nSaving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\r\nPlugins selected: Authenticator nginx, Installer nginx\r\nEnter email address (used for urgent renewal and security notices)\r\n (Enter 'c' to cancel): example@email.com\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nPlease read the Terms of Service at\r\nhttps:\/\/letsencrypt.org\/documents\/LE-SA-v1.2-November-15-2017.pdf. You must\r\nagree in order to register with the ACME server. Do you agree?\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: y\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nWould you be willing, once your first certificate is successfully issued, to\r\nshare your email address with the Electronic Frontier Foundation, a founding\r\npartner of the Let's Encrypt project and the non-profit organization that\r\ndevelops Certbot? We'd like to send you email about our work encrypting the web,\r\nEFF news, campaigns, and ways to support digital freedom.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: n\r\nAccount registered.\r\n<\/code><\/pre>\n<p>\u5f53\u8d26\u6237\u88ab\u521b\u5efa\u540e\uff0c\u53d1\u884c\u6b65\u9aa4\u5c06\u7ee7\u7eed\u8fdb\u884c\uff0c\u5e76\u6210\u529f\u5b8c\u6210\u3002<\/p>\n<pre class=\"post-pre\"><code>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nCongratulations! You have successfully enabled https:\/\/napspans.space\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n\r\nIMPORTANT NOTES:\r\n - Congratulations! Your certificate and chain have been saved at:\r\n   \/etc\/letsencrypt\/live\/napspans.space\/fullchain.pem\r\n   Your key file has been saved at:\r\n   \/etc\/letsencrypt\/live\/napspans.space\/privkey.pem\r\n   Your certificate will expire on 2022-09-18. To obtain a new or\r\n   tweaked version of this certificate in the future, simply run\r\n   certbot again with the \"certonly\" option. To non-interactively\r\n   renew *all* of your certificates, run \"certbot renew\"\r\n - If you like Certbot, please consider supporting our work by:\r\n\r\n   Donating to ISRG \/ Let's Encrypt:   https:\/\/letsencrypt.org\/donate\r\n   Donating to EFF:                    https:\/\/eff.org\/donate-le\r\n\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u66f4\u65b0nginx\u914d\u7f6e\u6587\u4ef6\uff0ccertbot\u4f1a\u8ffd\u52a0\u66f4\u65b0\u540e\u7684config\u6587\u4ef6\u3002<\/p>\n<p>\u786e\u8ba4\u80fd\u5426\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95eehttps\u3002<\/p>\n<h3>\u66f4\u65b0\u8bc1\u4e66<\/h3>\n<pre class=\"post-pre\"><code>sudo certbot renew\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>Saving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nProcessing \/etc\/letsencrypt\/renewal\/napspans.space.conf\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nCert not yet due for renewal\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nThe following certificates are not due for renewal yet:\r\n  \/etc\/letsencrypt\/live\/napspans.space\/fullchain.pem expires on 2022-09-18 (skipped)\r\nNo renewals were attempted.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n<\/code><\/pre>\n<p>\u5728\u6267\u884c\u7684\u7ed3\u679c\u4e2d\u5c06\u663e\u793a&#8221;skipped&#8221;\uff0c\u8fd9\u662f\u7531\u4e8e\u8bc1\u4e66\u7684\u6709\u6548\u671f\u5269\u4f59\u4e0d\u523030\u5929\uff0c\u4e3a\u4e86\u51cf\u8f7b\u8d1f\u8f7d\u800c\u4e0d\u5bf9\u5176\u8fdb\u884c\u66f4\u65b0\uff0c\u5c5e\u4e8e\u6b63\u5e38\u64cd\u4f5c\u3002<br \/>\n\u5982\u679c\u60a8\u975e\u5e38\u5e0c\u671b\u6210\u529f\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u9009\u9879\u6267\u884c\uff1a<br \/>\n&#8211;force-renew<br \/>\n\u60a8\u53ef\u4ee5\u5ffd\u7565\u8bc1\u4e66\u7684\u5269\u4f59\u6709\u6548\u671f\uff0c\u5f3a\u5236\u66f4\u65b0\u4e4b\u524d\u53d1\u653e\u7684\u6240\u6709\u8bc1\u4e66\u3002\u7136\u800c\uff0c\u6bcf\u5929\u5f3a\u5236\u66f4\u65b0\u6240\u6709\u8bc1\u4e66\u5e76\u4e0d\u9002\u5f53\uff0c\u53ef\u80fd\u4f1a\u89e6\u53caLet&#8217;s Encrypt\u8ba4\u8bc1\u673a\u6784\u7684\u901f\u7387\u9650\u5236\u3002<\/p>\n<p>&#8211;\u6d4b\u8bd5\u6a21\u5f0f\uff0c\u4e0d\u5b9e\u9645\u6267\u884c\u66f4\u65b0\u64cd\u4f5c<\/p>\n<h3>\u81ea\u52a8\u66f4\u65b0\u8bbe\u7f6e<\/h3>\n<pre class=\"post-pre\"><code>sudo crontab -e\r\n<\/code><\/pre>\n<p>\u4f7f\u7528root\u6743\u9650\u5411crontab\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u6267\u884c\u547d\u4ee4\u3002<br \/>\n\u7531\u4e8e\u66f4\u65b0\u9700\u8981\u4f7f\u7528sudo\u6765\u6267\u884c\uff0c\u6240\u4ee5\u8fd9\u91cc\u662f\u5f88\u91cd\u8981\u7684\u3002<br \/>\n\u5728Linux\u4e2d\uff0c&#8221;sudo crontab -e&#8221;\u548c&#8221;crontab -e&#8221;\u6709\u4ec0\u4e48\u533a\u522b\u3002<\/p>\n<pre class=\"post-pre\"><code>0 0 1 * * sudo certbot renew &amp;&amp; systemctl restart nginx\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u53ea\u6709\u572860\u5929\u540e\u624d\u80fd\u786e\u5b9a\u8fd9\u4e2acrontab\u662f\u5426\u771f\u7684\u4f1a\u88ab\u66f4\u65b0\u3002<br \/>\n\u5982\u679c\u60f3\u7acb\u5373\u77e5\u9053\u662f\u5426\u8fdb\u884c\u4e86\u66f4\u65b0\u5ba1\u6838\uff0c\u8bf7\u5728crontab\u6587\u4ef6\u4e2d\u6dfb\u52a0&#8211;force-renew\u9009\u9879\uff0c\u5e76\u5728\u7b2c\u4e8c\u5929\u68c0\u67e5\u7f51\u7ad9\u7684\u8bc1\u4e66\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>\u603b\u7ed3\u5982\u4e0b\u3002<\/h1>\n<p>\u9019\u7bc7\u6587\u7ae0\u50c5\u4f5c\u70ba\u5099\u5fd8\u9304\uff0c\u63d0\u9192\u8acb\u6ce8\u610f\u5167\u5bb9\u53ef\u80fd\u50c5\u9069\u7528\u65bc\u7279\u5b9a\u60c5\u6cc1\u3002\u8b1d\u8b1d\u8f9b\u82e6\u5de5\u4f5c\u3002<\/p>\n<h1>\u4e9a\u9a6c\u900a\u8d2d\u4e70\u94fe\u63a5<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/187-0.png\" alt=\"undefined\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/188-0.png\" alt=\"undefined\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/189-0.png\" alt=\"undefined\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/190-0.png\" alt=\"undefined\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8e\u4e0d\u5c0f\u5fc3\u7834\u574f\u4e86\u7f51\u7edc\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u4f5c\u4e3a\u5907\u5fd8\u5f55\uff0c\u6211\u5c06\u8bb0\u5f55\u4ece\u96f6\u5f00\u59cb\u4f7f\u7528\u6811\u8393\u6d3e\u642d\u5efa\u65e0\u5934Nginx\u7f51\u7edc\u670d\u52a1\u5668\u7684\u6b65\u9aa4\u3002\u65e0\u9700 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33089","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5nginx-web\u670d\u52a1\u5668\u7684\u6b65\u9aa4\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4\" \/>\n<meta property=\"og:description\" content=\"\u7531\u4e8e\u4e0d\u5c0f\u5fc3\u7834\u574f\u4e86\u7f51\u7edc\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u4f5c\u4e3a\u5907\u5fd8\u5f55\uff0c\u6211\u5c06\u8bb0\u5f55\u4ece\u96f6\u5f00\u59cb\u4f7f\u7528\u6811\u8393\u6d3e\u642d\u5efa\u65e0\u5934Nginx\u7f51\u7edc\u670d\u52a1\u5668\u7684\u6b65\u9aa4\u3002\u65e0\u9700 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5nginx-web\u670d\u52a1\u5668\u7684\u6b65\u9aa4\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-16T04:20:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T15:40:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/8-1.png\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/\",\"name\":\"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-07-16T04:20:26+00:00\",\"dateModified\":\"2024-04-29T15:40:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5nginx-web\u670d\u52a1\u5668\u7684\u6b65\u9aa4\/","og_locale":"zh_CN","og_type":"article","og_title":"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4","og_description":"\u7531\u4e8e\u4e0d\u5c0f\u5fc3\u7834\u574f\u4e86\u7f51\u7edc\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u4f5c\u4e3a\u5907\u5fd8\u5f55\uff0c\u6211\u5c06\u8bb0\u5f55\u4ece\u96f6\u5f00\u59cb\u4f7f\u7528\u6811\u8393\u6d3e\u642d\u5efa\u65e0\u5934Nginx\u7f51\u7edc\u670d\u52a1\u5668\u7684\u6b65\u9aa4\u3002\u65e0\u9700 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5nginx-web\u670d\u52a1\u5668\u7684\u6b65\u9aa4\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-07-16T04:20:26+00:00","article_modified_time":"2024-04-29T15:40:12+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d158037434c4406bfe97b\/8-1.png"}],"author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/","name":"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-07-16T04:20:26+00:00","dateModified":"2024-04-29T15:40:12+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Nginx Web\u670d\u52a1\u5668\u7684\u6b65\u9aa4"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e5%ae%89%e8%a3%85nginx-web%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e6%ad%a5%e9%aa%a4\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=33089"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33089\/revisions"}],"predecessor-version":[{"id":88346,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33089\/revisions\/88346"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=33089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=33089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=33089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}