{"id":73,"date":"2020-09-27T22:13:49","date_gmt":"2020-09-27T14:13:49","guid":{"rendered":"https:\/\/www.lazybirds.top\/?p=73"},"modified":"2021-10-19T23:56:48","modified_gmt":"2021-10-19T15:56:48","slug":"lnmp%e7%8e%af%e5%a2%83%e4%b8%8b%e5%88%a9%e7%94%a8nginx%e5%8f%8d%e4%bb%a3wikipedia","status":"publish","type":"post","link":"https:\/\/www.lazybirds.top\/?p=73","title":{"rendered":"LNMP\u73af\u5883\u4e0b,\u5229\u7528Nginx\u53cd\u4ee3Wikipedia"},"content":{"rendered":"\n<h2>\u524d\u8bb0<\/h2>\n\n\n\n<p>\u4e4b\u524d\u4e00\u76f4\u4f7f\u7528ShadowsocksR\u4ee3\u7406\u7f51\u7edc\uff0c\u4f46\u662f\u8fd9\u9700\u8981\u5b89\u88c5\u8f6f\u4ef6\uff0c\u8fd8\u662f\u5f88\u9ebb\u70e6\u7684\u3002<\/p>\n\n\n\n<p>\u8003\u8651\u5230\u8bbf\u95ee\u5916\u7f51\u7684\u4e3b\u8981\u9700\u6c42\u4e3a\u7ef4\u57fa\u767e\u79d1\uff0c\u6240\u4ee5\u5c31\u7740\u624b\u4e8e\u5236\u4f5c\u4e00\u4e2a\u7ef4\u57fa\u955c\u50cf\u7ad9\u3002<\/p>\n\n\n\n<p>\u4e86\u89e3\u5230\u4e00\u5171\u6709\u4e24\u79cd\u65b9\u6cd5\uff0c\u5206\u522b\u4e3a<strong>\u901a\u8fc7Kiwix\u8bbf\u95ee\u672c\u5730\u5b58\u50a8\u7684ZIM\u6587\u4ef6<\/strong>\u548c<strong>\u901a\u8fc7Nginx\u53cd\u4ee3wikipedia.org<\/strong>\u3002<\/p>\n\n\n\n<p>\u524d\u8005\u4e0d\u4ec5\u65f6\u6548\u6027\u5dee\u8fd8\u9700\u8981\u5360\u7528\u5927\u91cf\u7a7a\u95f4\uff0c\u5bf9\u4e8e\u6211\u5bd2\u9178\u7684\u670d\u52a1\u5668\u6765\u8bf4\u662f\u4e2a\u5927\u95ee\u9898\uff0c\u56e0\u6b64\u91c7\u7528\u4e86\u7b2c\u4e8c\u4e2a\u65b9\u6848\u3002<\/p>\n\n\n\n<p>\u7279\u522b\u611f\u8c22<a href=\"https:\/\/minicloud.xyz\">Johnson<\/a>\u7684\u6307\u70b9\u3001\u7f51\u4e0a\u5927\u4f6c\u4eec\u7684\u6559\u7a0b\uff0c\u624d\u6709\u4e86\u5982\u4eca<a href=\"https:\/\/wiki.lazybirds.top\">\u8fd9\u4e2a<\/a>\u7ef4\u57fa\u955c\u50cf\u7ad9\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2>\u51c6\u5907<\/h2>\n\n\n\n<ol><li>\u4e00\u53f0\u6e2f\u6fb3\u53f0\u6216\u56fd\u5916\u7684VPS<\/li><li>Linux\u7cfb\u7edf\uff08\u7b14\u8005\u4f7f\u7528\u7684\u662f<code>Ubuntu 18.04 LTS<\/code>\uff09<\/li><li>LNMP\u73af\u5883\uff08\u7b14\u8005\u4f7f\u7528\u7684\u662f<code>LNMP 1.6<\/code>\uff0c\u5b89\u88c5\u8be6\u89c1<a href=\"https:\/\/lnmp.org\/install.html\">LNMP\u5b98\u7f51<\/a>\uff09<\/li><\/ol>\n\n\n\n<h2>\u6559\u7a0b<\/h2>\n\n\n\n<h3>1. \u4e3a\u5df2\u5b89\u88c5\u7684LNMP\u7f16\u8bd1<code>ngx_http_substitutions_filter_module<\/code>\u6a21\u5757<\/h3>\n\n\n\n<p>\u4e0b\u8f7d<code>ngx_http_substitutions_filter_module<\/code>\u6a21\u5757<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">cd \/root\ngit clone \"https:\/\/github.com\/yaoweibin\/ngx_http_substitutions_filter_module.git\"<\/code><\/pre>\n\n\n\n<p>\u7f16\u8f91<code>lnmp.conf<\/code>\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">vim \/root\/lnmp1.6\/lnmp.conf<\/code><\/pre>\n\n\n\n<p>\u5728<code>Nginx_Modules_Options<\/code>\u4e00\u9879\u540e\u7684\u5355\u5f15\u53f7\u95f4\u6dfb\u52a0 <code>--add-module=\/root\/ngx_http_substitutions_filter_module<\/code><\/p>\n\n\n\n<p>\u67e5\u770b<code>Nginx<\/code>\u7248\u672c\u53f7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">nginx -V<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5<code>ngx_http_substitutions_filter_module<\/code>\u6a21\u5757<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">cd \/root\/lnmp1.6\n.\/upgrade.sh<\/code><\/pre>\n\n\n\n<p>\u9009\u62e9<code>Update Nginx<\/code><\/p>\n\n\n\n<p>\u5728<code>Current Nginx Version<\/code>\u4e2d\u8f93\u5165\u4f60\u5f53\u524d\u7684<code>Nginx<\/code>\u7248\u672c\u53f7<\/p>\n\n\n\n<p>\u4e0d\u505c\u56de\u8f66\u5373\u53ef<\/p>\n\n\n\n<p>\u7f16\u8bd1\u7ed3\u675f\u65f6\uff0c\u8f93\u5165<code>nginx -V<\/code>\u68c0\u67e5\u7f16\u8bd1<\/p>\n\n\n\n<p>\u4f60\u5c06\u770b\u5230<code>--add-module=\/root\/ngx_http_substitutions_filter_module<\/code><\/p>\n\n\n\n<h3>2.\u6dfb\u52a0vhost<\/h3>\n\n\n\n<p>\u786e\u4fdd\u76f8\u5173\u57df\u540d\u5df2\u6dfb\u52a0\u81f3\u4f60\u7684DNS\u89e3\u6790\u670d\u52a1\u5546<\/p>\n\n\n\n<p>\u4ee5\u672c\u7ad9\u4e3a\u4f8b\uff0c\u5206\u522b\u4e3a\uff1a<\/p>\n\n\n\n<p><code>wiki.lazybirds.top<\/code><\/p>\n\n\n\n<p><code>*.wiki.lazybirds.top<\/code><\/p>\n\n\n\n<p>\u5b9e\u9645\u4f7f\u7528\u7684\u4e3a\uff1a<\/p>\n\n\n\n<p><code>wiki.lazybirds.top<\/code><\/p>\n\n\n\n<p><code>lang.wiki.lazybirds.top<\/code><\/p>\n\n\n\n<p><code>lang.m.wiki.lazybirds.top<\/code><\/p>\n\n\n\n<p><code>up.wiki.lazybirds.top<\/code><\/p>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n\n\n\n<p><strong>\u5c06<code>lazybirds.top<\/code>\u66ff\u6362\u6210\u4f60\u81ea\u5df1\u7684\u57df\u540d<\/strong><\/p>\n\n\n\n<p><strong>\u5c06<code>lang<\/code>\u66ff\u6362\u4e3a\u4f60\u5e0c\u671b\u6dfb\u52a0\u7684\u7ef4\u57fa\u8bed\u8a00\uff0c\u5982<code>en<\/code>\u3001<code>zh<\/code>\u5206\u522b\u5bf9\u5e94\u82f1\u6587\u4e2d\u6587\u7ef4\u57fa\uff0c\u4e0b\u540c<\/strong><\/p>\n\n\n\n<p>\u65b0\u5efa\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">lnmp vhost add<\/code><\/pre>\n\n\n\n<p>\u4f9d\u6b21\u6dfb\u52a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">wiki.lazybirds.top<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">www.wiki.lazybirds.top\nlang.wiki.lazybirds.top\nlang.m.wiki.lazybirds.top\nup.wiki.lazybirds.top<\/code><\/pre>\n\n\n\n<p>\u8def\u5f84\u9ed8\u8ba4\u5373\u53ef<\/p>\n\n\n\n<p>\u9009<code>n<\/code>\u76f4\u5230\u51fa\u73b0<code>Add SSL Certificate (y\/n)<\/code> \u4e00\u9879\uff0c\u9009<code>y<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">1: Use your Own SSL Certificate and Key \n2: Use Let's Encrypt to create SSL Certificate and Key \nEnter 1 or 2:<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u586b2<\/p>\n\n\n\n<p>\u5b8c\u6210\u914d\u7f6e\u5373\u53ef<\/p>\n\n\n\n<h3>3.\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<p>\u914d\u7f6e<code>wiki.lazybirds.top.conf<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">vim \/usr\/local\/nginx\/conf\/vhost\/wiki.lazybirds.top.conf<\/code><\/pre>\n\n\n\n<p>\u7528\u4ee5\u4e0b\u4ee3\u7801\u8986\u76d6\u539f\u6587\u4ef6<\/p>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n\n\n\n<p><strong>\u5c06<code>lazybirds.top<\/code>\u66ff\u6362\u6210\u4f60\u81ea\u5df1\u7684\u57df\u540d<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"nginx\" class=\"language-nginx line-numbers\">server {\n    server_name up.wiki.lazybirds.top;\n    listen 80;\n    listen 443 ssl http2;\n    resolver 8.8.8.8;\n#    resolver 127.0.0.1 valid=30s;\n\n    ssl_certificate \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/fullchain.cer;\n    ssl_certificate_key \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/wiki.lazybirds.top.key;\n    ssl_session_timeout 5m;\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;\n    ssl_prefer_server_ciphers on;\n    ssl_ciphers \"TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5\";\n    ssl_session_cache builtin:1000 shared:SSL:10m;\n    # openssl dhparam -out \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem 2048\n    ssl_dhparam \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem;\n    \n    if ($http_x_forwarded_proto = 'http')\n    {\n        return 301 $server_name$request_uri;\n    }\n\n    location \/ {\n        proxy_pass https:\/\/upload.wikimedia.org;\n        proxy_cookie_domain upload.wikimedia.org up.wiki.lazybirds.top;\n        proxy_buffering off;\n        proxy_set_header X-Real_IP $remote_addr;\n        proxy_set_header User-Agent $http_user_agent;\n        proxy_set_header referer \"https:\/\/upload.wikimedia.org$request_uri\";\n    }\n}\n\nserver {\n    server_name  wiki.lazybirds.top;\n    listen 80;\n    listen 443 ssl http2;\n    resolver 8.8.8.8;\n\n    ssl_certificate \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/fullchain.cer;\n    ssl_certificate_key \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/wiki.lazybirds.top.key;\n    ssl_session_timeout 5m;\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;\n    ssl_prefer_server_ciphers on;\n    ssl_ciphers \"TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5\";\n    ssl_session_cache builtin:1000 shared:SSL:10m;\n    # openssl dhparam -out \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem 2048\n    ssl_dhparam \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem;\n    \n    if ($http_x_forwarded_proto = 'http')\n    {\n        return 301 $server_name$request_uri;\n    }\n\n    location \/ {\n        proxy_pass https:\/\/www.wikipedia.org;\n        proxy_buffering off;\n\n        proxy_redirect https:\/\/www.wikipedia.org\/ http:\/\/wiki.lazybirds.top\/;\n        proxy_cookie_domain www.wikipedia.org wiki.lazybirds.top;\n        proxy_redirect ~^https:\/\/([\\w\\.]+).wikipedia.org\/(.*?)$ http:\/\/$1.wiki.lazybirds.top\/$2;\n\n        proxy_set_header X-Real_IP $remote_addr;\n        proxy_set_header User-Agent $http_user_agent;\n        proxy_set_header Accept-Encoding '';\n        proxy_set_header referer \"https:\/\/$proxy_host$request_uri\";\n\n        subs_filter_types text\/css text\/xml text\/javascript application\/javascript application\/json;\n        subs_filter .wikipedia.org .wiki.lazybirds.top;\n        subs_filter \/\/wikipedia.org \/\/wiki.lazybirds.top;\n        subs_filter upload.wikimedia.org up.wiki.lazybirds.top;\n    }\n}\n\nserver {\n    server_name  ~^(?&lt;subdomain&gt;[^.]+)\\.wiki\\.ericdrive\\.ml$;\n    listen 80;\n    listen 443 ssl http2;\n    resolver 8.8.8.8;\n\n    ssl_certificate \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/fullchain.cer;\n    ssl_certificate_key \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/wiki.lazybirds.top.key;\n    ssl_session_timeout 5m;\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;\n    ssl_prefer_server_ciphers on;\n    ssl_ciphers \"TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5\";\n    ssl_session_cache builtin:1000 shared:SSL:10m;\n    # openssl dhparam -out \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem 2048\n    ssl_dhparam \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem;\n    \n    if ($http_x_forwarded_proto = 'http')\n    {\n        return 301 $subdomain.wiki.lazybirds.top$request_uri;\n    }\n\n    location \/ {\n        proxy_pass https:\/\/$subdomain.wikipedia.org;\n        proxy_buffering off;\n\n        proxy_redirect https:\/\/$subdomain.wikipedia.org\/ http:\/\/$subdomain.wiki.lazybirds.top\/;\n        proxy_redirect https:\/\/$subdomain.m.wikipedia.org\/ http:\/\/$subdomain.m.wiki.lazybirds.top\/;\n        proxy_cookie_domain $subdomain.wikipedia.org $subdomain.wiki.lazybirds.top;\n        proxy_redirect ~^https:\/\/([\\w\\.]+).wikipedia.org\/(.*?)$ http:\/\/$1.wiki.lazybirds.top\/$2;\n\n        proxy_set_header X-Real_IP $remote_addr;\n        proxy_set_header User-Agent $http_user_agent;\n        proxy_set_header Accept-Encoding ''; \n        proxy_set_header referer \"https:\/\/$proxy_host$request_uri\";\n\n        subs_filter_types text\/css text\/xml text\/javascript application\/javascript application\/json;\n        subs_filter .wikipedia.org .wiki.lazybirds.top;\n        subs_filter \/\/wikipedia.org \/\/wiki.lazybirds.top;\n        subs_filter 'https:\/\/([^.]+).wiki' 'http:\/\/$1.wiki' igr; \n        subs_filter upload.wikimedia.org up.wiki.lazybirds.top;\n    }\n}\n\nserver {\n    server_name ~^(?&lt;subdomain&gt;[^.]+)\\.m\\.wiki\\.ericdrive\\.ml$;\n    listen 80;\n    listen 443 ssl http2;\n    resolver 8.8.8.8;\n\n    ssl_certificate \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/fullchain.cer;\n    ssl_certificate_key \/usr\/local\/nginx\/conf\/ssl\/wiki.lazybirds.top\/wiki.lazybirds.top.key;\n    ssl_session_timeout 5m;\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;\n    ssl_prefer_server_ciphers on;\n    ssl_ciphers \"TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5\";\n    ssl_session_cache builtin:1000 shared:SSL:10m;\n    # openssl dhparam -out \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem 2048\n    ssl_dhparam \/usr\/local\/nginx\/conf\/ssl\/dhparam.pem;\n    \n    if ($http_x_forwarded_proto = 'http')\n    {\n        return 301 $subdomain.m.wiki.lazybirds.top$request_uri;\n    }\n\n    location \/ {\n        proxy_pass https:\/\/$subdomain.m.wikipedia.org;\n        proxy_buffering off;\n\n        proxy_redirect https:\/\/$subdomain.m.wikipedia.org\/ http:\/\/$subdomain.m.wiki.lazybirds.top\/;\n        proxy_cookie_domain $subdomain.m.wikipedia.org $subdomain.m.wiki.lazybirds.top;\n\n        proxy_set_header X-Real_IP $remote_addr;\n        proxy_set_header User-Agent $http_user_agent;\n        proxy_set_header Accept-Encoding ''; \n        proxy_set_header referer \"https:\/\/$proxy_host$request_uri\";\n\n        subs_filter_types text\/css text\/xml text\/javascript application\/javascript application\/json;\n        subs_filter .wikipedia.org .wiki.lazybirds.top;\n        subs_filter \/\/wikipedia.org \/\/wiki.lazybirds.top;\n        subs_filter 'https:\/\/([^.]+).m.wiki' 'http:\/\/$1.m.wiki' igr; \n        subs_filter upload.wikimedia.org up.wiki.lazybirds.top;\n    }\n}<\/code><\/pre>\n\n\n\n<h3>4.\u91cd\u542f<code>Nginx<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">lnmp nginx restart<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8bb0 \u4e4b\u524d\u4e00\u76f4\u4f7f\u7528ShadowsocksR\u4ee3\u7406\u7f51\u7edc\uff0c\u4f46\u662f\u8fd9\u9700\u8981\u5b89\u88c5\u8f6f\u4ef6\uff0c\u8fd8\u662f\u5f88\u9ebb\u70e6\u7684\u3002 \u8003\u8651\u5230\u8bbf\u95ee\u5916\u7f51\u7684\u4e3b\u8981\u9700 &hellip; <a href=\"https:\/\/www.lazybirds.top\/?p=73\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cLNMP\u73af\u5883\u4e0b,\u5229\u7528Nginx\u53cd\u4ee3Wikipedia\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[8,9],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts\/73"}],"collection":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":0,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}