{"id":2078,"date":"2020-01-20T12:53:35","date_gmt":"2020-01-20T04:53:35","guid":{"rendered":"https:\/\/www.bluemountain.pw\/?p=2078"},"modified":"2020-01-20T18:12:52","modified_gmt":"2020-01-20T10:12:52","slug":"%e6%8a%80%e6%9c%afnginx%e5%8f%8d%e4%bb%a3frpnginxhttps%e6%90%ad%e5%bb%ba%e6%8a%80%e6%9c%af%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.bluemountain.pw\/?p=2078","title":{"rendered":"[\u8fd9\u4e9b\u5929\u7684\u4e00\u5929]nginx\u53cd\u4ee3+frp+nginx+https\u642d\u5efa\u6280\u672f\u603b\u7ed3"},"content":{"rendered":"<p>\u5982\u4f60\u6240\u89c1\uff0c\u4f8b\u884c\u7684\u300a\u6211\u76842019\u6700\u7231\u300b\u4e0e\u300a2020\u65b0\u5e74\u8d3a\u8bcd\u300b\u8fdf\u5230\u4e86\u534a\u4e2a\u591a\u6708\u3002BLOG\u4e5f2\u4e2a\u591a\u6708\u6ca1\u6709\u66f4\u65b0\u3002\u4e3b\u8981\u539f\u56e0\u662f\u56e0\u4e3a\u4e00\u76f4\u5728\u8fdb\u884c\u7684https\u6280\u672f\u53d7\u963b\uff0c\u4ee5\u81f3\u4e8e\u4ea7\u751f\u754f\u96be\u62d6\u5ef6\u60c5\u7eea\u3002<\/p>\n<p>\u7ecf\u8fc7\u8fd1\u534a\u6708\u7684\u9ad8\u5f3a\u5ea6\u79d1\u7814\uff0c\u53c2\u8003\u8bf8\u591a\u6559\u7a0b\uff0c\u7ec8\u4e8e\u653b\u514b\u76f8\u5173\u96be\u9898\u3002\u73b0\u8fdb\u884c\u6280\u672f\u603b\u7ed3\u4ee5\u98e8\u8bfb\u8005\u3002\u672c\u6587\u4e3b\u8981\u9762\u5411\u6280\u672f\u6c34\u5e73\u8f83\u4f4e\u7684\u8bfb\u8005\u3002<\/p>\n<p>\u4e00\u3001\u670d\u52a1\u5185\u5bb9<\/p>\n<p>\u57df\u540d\u89e3\u6790\u81f3VPS\uff0cVPS\uff0880\u7aef\u53e3\u88ab\u5176\u4ed6\u811a\u672c\u5360\u636e\uff09\u901a\u8fc7nginx\u53cd\u4ee3\u81f3frps\u3002<\/p>\n<p>\u5ba2\u6237\u7aef\uff08\u6811\u8393\u6d3e\uff09frpc\u8fde\u63a5vps\u7aeffrps\uff0c\u6811\u8393\u6d3e\u901a\u8fc7nginx\u642d\u5efa\u7f51\u76d8\u53ca\u535a\u5ba2\u3002<\/p>\n<p>\u4e8c\u3001\u6280\u672f\u96be\u70b9<\/p>\n<p>\u57df\u540d\u89e3\u6790\u3001http\u901a\u8fc7frp\u8fdb\u884c\u5185\u7f51\u7a7f\u900f\u5728\u7f51\u7edc\u4e0a\u6559\u7a0b\u5f88\u591a\uff0c\u5373\u4f7f\u901a\u8fc7\u5b98\u65b9\u6587\u6863\u4e5f\u6781\u6613\u4e60\u5f97\u3002\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<p>\u672c\u6587\u4e3b\u8981\u4ecb\u7ecdhttps\u901a\u8fc7frp\u8fdb\u884c\u5185\u7f51\u7a7f\u900f\u3002<\/p>\n<p>VPS\u7aef\uff1a<\/p>\n<p>1\u3001\u57df\u540d\u89e3\u6790\u81f3vps\u540e\uff0c\u6211\u4f7f\u7528\u4e86lnmp\u4e00\u952e\u5305\u642d\u5efanginx\u73af\u5883\u3002\uff08\u6559\u7a0b https:\/\/wzfou.com\/lnmp-1-6\/\uff09\u901a\u8fc7\u811a\u672c\u547d\u4ee4\u76f4\u63a5\u6dfb\u52a0\u865a\u62df\u4e3b\u673a\u3002\u671f\u95f4\uff0c\u901a\u8fc7Letsencrypt\u83b7\u5f97\u81ea\u52a8\u7eed\u671f\u7684\u514d\u8d39SSL\u8bc1\u4e66\uff08\u82e5\u4e2d\u95f4\u5361\u4f4f\uff0c\u9700\u5347\u7ea7acme.sh\u811a\u672c\uff09\u3002<\/p>\n<p>2\u3001\u7f16\u8f91\u5bf9\u5e94\u865a\u62df\u4e3b\u673a\u7684conf\u6587\u4ef6\u3002<\/p>\n<p>server<br \/>\n{<br \/>\nlisten 80;<br \/>\nlisten 443 ssl http2;<br \/>\nserver_name <span style=\"color: #ff0000;\">aaa.aaa.aaa #\u8fd9\u91cc\u586b\u5199\u4f60\u7684\u57df\u540d<\/span><br \/>\ncharset utf-8;<br \/>\nif ($server_port !~ 443){<br \/>\nrewrite ^(\/.*)$ https:\/\/$host$1 permanent;<br \/>\n}<span style=\"color: #ff0000;\">#\u901a\u8fc7\u8fd9\u6bb5\u5c06http\u5168\u90e8\u8f6c\u4e3ahttps<\/span><br \/>\n<span style=\"color: #ff0000;\">ssl_certificate \/usr\/local\/nginx\/conf\/ssl\/aaa\/aaa;#\u8fd9\u91cc\u586b\u5199\u5bf9\u5e94cer\u6587\u4ef6\u8def\u5f84\uff0c\u5728\u539f\u6709\u6587\u4ef6\u4e2d\u6709\u76f8\u5173\u5b57\u6bb5<\/span><br \/>\n<span style=\"color: #ff0000;\">ssl_certificate_key \/usr\/local\/nginx\/conf\/ssl\/aaa\/aaa;#\u8fd9\u91cc\u586b\u5199\u5bf9\u5e94cer\u6587\u4ef6\u8def\u5f84\uff0c\u5728\u539f\u6709\u6587\u4ef6\u4e2d\u6709\u76f8\u5173\u5b57\u6bb5<\/span><br \/>\nssl_protocols TLSv1.1 TLSv1.2;<br \/>\nssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;<br \/>\nssl_prefer_server_ciphers on;<br \/>\nssl_session_cache shared:SSL:10m;<br \/>\nssl_session_timeout 10m;<br \/>\nerror_page 497 https:\/\/$host$request_uri;<\/p>\n<p>location \/ {<br \/>\nresolver 8.8.8.8;<br \/>\nproxy_ssl_server_name on;<br \/>\nproxy_set_header X-Real-IP $remote_addr;<br \/>\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\nproxy_set_header X-Forwarded-Proto $scheme;<br \/>\nproxy_set_header Host $host;<br \/>\nproxy_pass https:\/\/$host:aaaa;<\/p>\n<p>}<span style=\"color: #ff0000;\">#\u901a\u8fc7\u8fd9\u6bb5\u5c06\u76f8\u5173\u8bf7\u6c42\u8f6c\u53d1\u81f3\u4e3b\u673a\u7684aaaa\u7aef\u53e3<\/span><br \/>\n}<\/p>\n<p>\u91cd\u542flnmp\u670d\u52a1<\/p>\n<p>&nbsp;<\/p>\n<p>3\u3001\u4e0b\u8f7d\u6700\u65b0\u7248frp\u811a\u672c\uff08https:\/\/github.com\/fatedier\/frp\/releases\uff09\u3002\u89e3\u538b\u3001\u8bbe\u7f6e\u81ea\u52a8\u8fd0\u884c\u4e0d\u8d58\u8ff0\u3002<\/p>\n<p>\u5220\u53bbfrpc\u76f8\u5173\u5185\u5bb9\uff0c\u53ea\u7559\u4e0bfrps\u76f8\u5173\u3002\u7f16\u8f91frps.ini\u3002<\/p>\n<p>[common]<br \/>\nbind_addr =\u00a0<span style=\"color: #ff0000;\">vps ip\u5730\u5740<\/span><br \/>\ndashboard_addr = <span style=\"color: #ff0000;\">vps ip\u5730\u5740<\/span><br \/>\nbind_port =\u00a0\u4efb\u610f\u975e\u5360\u7528\u7aef\u53e3<br \/>\nkcp_bind_port =\u00a0\u540c\u4e0a\u7aef\u53e3<br \/>\ntoken = \u4efb\u610f\u5bc6\u7801\uff08\u7528\u4e8efrp\u8fde\u63a5\uff09<br \/>\nvhost_http_port =\u00a0eeee\uff08\u4efb\u610f\u975e\u5360\u7528\u7aef\u53e3\uff09<br \/>\nvhost_https_port = aaaa\uff08\u540c2\u3001\u4e2d\u7684aaaa\uff09<br \/>\ntcp_mux=true<br \/>\ndashboard_port = \u4efb\u610f\u975e\u5360\u7528\u7aef\u53e3<br \/>\ndashboard_user =\u00a0\u4efb\u610f\u7528\u6237\u540d<br \/>\ndashboard_pwd = \u4efb\u610f\u5bc6\u7801\uff08\u7528\u4e8e\u767b\u5f55\u9762\u677f\uff09<\/p>\n<p>\u8f7d\u5165frps.ini\u6587\u4ef6\uff0c\u542f\u52a8frps\u670d\u52a1\u3002\u53ef\u901a\u8fc7\u8bbf\u95eevps ip:\u9762\u677f\u7aef\u53e3\u6765\u83b7\u77e5frps\u670d\u52a1\u8fd0\u884c\u72b6\u6001\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u5ba2\u6237\u7aef\uff1a<\/p>\n<p>1\u3001lnmp\u4e00\u952e\u5305\u642d\u5efanginx\u73af\u5883\u3002\u901a\u8fc7\u811a\u672c\u547d\u4ee4\u76f4\u63a5\u6dfb\u52a0\u865a\u62df\u4e3b\u673a\u3002\u671f\u95f4\uff0c\u901a\u8fc7Letsencrypt\u83b7\u5f97\u81ea\u52a8\u7eed\u671f\u7684\u514d\u8d39SSL\u8bc1\u4e66\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u56e0\u4e3a\u57df\u540d\u672a\u89e3\u6790\u81f3\u6b64\uff0c\u6545\u8bc1\u4e66\u7533\u8bf7\u5fc5\u5b9a\u5931\u8d25\u3002<\/p>\n<p>2\u3001\u5c06vps\u7aef\u7684\u8bc1\u4e66\u590d\u5236\u5230\u76f8\u5e94\u76ee\u5f55\u3002\uff08\u56e0\u8bc1\u4e66\u5230\u671f\u4f1a\u5931\u6548\uff0c\u6b64\u5904\u53ef\u901a\u8fc7\u8ba1\u5212\u4efb\u52a1\u4f7f\u5ba2\u6237\u7aef\u81ea\u52a8\u4ecevps\u7aef\u83b7\u53d6\u8bc1\u4e66\uff0c\u6b64\u5904\u4e0d\u8d58\u8a00\uff09<\/p>\n<p>3\u3001\u7f16\u8f91\u5bf9\u5e94\u865a\u62df\u4e3b\u673a\u7684conf\u6587\u4ef6\u3002<\/p>\n<p>server<br \/>\n{<br \/>\nlisten\u00a0<span style=\"color: #ff0000;\">cccc<\/span>\u00a0ssl http2; #cccc\u662f\u4efb\u610f\u6ca1\u6709\u88ab\u5360\u7528\u7684\u7aef\u53e3<br \/>\n#listen [::]:443 ssl http2;<br \/>\nserver_name <span style=\"color: #ff0000;\">cccc.cccc.cccc; #\u4f60\u7684\u57df\u540d<\/span><br \/>\nindex.html ;<br \/>\n<span style=\"color: #ff0000;\">root \/????\/????\/????; #\u865a\u62df\u4e3b\u673a\u8def\u5f84<\/span><\/p>\n<p><span style=\"color: #ff0000;\">ssl_certificate \/usr\/local\/nginx\/conf\/ssl\/????\/????; #\u4ecevps\u590d\u5236\u8fc7\u6765\u7684\u8bc1\u4e66\u6587\u4ef6\uff0c\u6ce8\u610f\u6743\u9650<\/span><br \/>\n<span style=\"color: #ff0000;\">ssl_certificate_key \/usr\/local\/nginx\/conf\/ssl\/????\/????; #\u4ecevps\u590d\u5236\u8fc7\u6765\u7684\u8bc1\u4e66\u6587\u4ef6\uff0c\u6ce8\u610f\u6743\u9650<\/span><br \/>\nssl_session_timeout 5m;<br \/>\nssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;<br \/>\nssl_prefer_server_ciphers on;<br \/>\nssl_session_cache builtin:1000 shared:SSL:10m;<\/p>\n<p>include rewrite\/none.conf;<\/p>\n<p>include enable-php-pathinfo.conf;<\/p>\n<p>location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$<br \/>\n{<br \/>\nexpires 30d;<br \/>\n}<\/p>\n<p>location ~ .*\\.(js|css)?$<br \/>\n{<br \/>\nexpires 12h;<br \/>\n}<\/p>\n<p>location ~ \/.well-known {<br \/>\nallow all;<br \/>\n}<\/p>\n<p>location ~ \/\\.<br \/>\n{<br \/>\ndeny all;<br \/>\n}<\/p>\n<p><span style=\"color: #ff0000;\">access_log \/home\/wwwlogs\/????; #log\u8def\u5f84\uff0c\u53ef\u6709\u53ef\u65e0<\/span><br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n<p>4\u3001\u4e0b\u8f7d\u6700\u65b0\u7248frp\u811a\u672c\uff08\u7248\u672c\u9700\u4e0evps\u7aef\u4e00\u81f4\uff09\u3002\u89e3\u538b\u3001\u8bbe\u7f6e\u81ea\u52a8\u8fd0\u884c\u4e0d\u8d58\u8ff0\u3002<\/p>\n<p>\u5220\u53bbfrps\u76f8\u5173\u5185\u5bb9\uff0c\u53ea\u7559\u4e0bfrpc\u76f8\u5173\u3002\u7f16\u8f91frpc.ini\u3002<\/p>\n<p>[common]<br \/>\nserver_addr = <span style=\"color: #ff0000;\">vps ip\u5730\u5740<\/span><br \/>\nserver_port = \u4efb\u610f\u975e\u5360\u7528\u7aef\u53e3\uff0c\u540cvps\u7aef\u7684bind_port<br \/>\nlog_max_days = 3<br \/>\ntoken =\u00a0 \u4efb\u610f\u5bc6\u7801\uff0c\u540cVPS\u7aef<br \/>\ntcp_mux = true<br \/>\nprotocol = tcp<\/p>\n<p>[\u4efb\u610f\u670d\u52a1\u540d]<br \/>\ntype = https<br \/>\nlocal_ip = 127.0.0.1<br \/>\nlocal_port = cccc \uff08\u540c\u5ba2\u6237\u7aefconf\u6587\u4ef6\u4e2d\u7684\uff09<br \/>\nuse_encryption = false<br \/>\nuse_compression = true<br \/>\ncustom_domains = <span style=\"color: #ff0000;\">cccc.cccc.cccc; #\u4f60\u7684\u57df\u540d<\/span><\/p>\n<p>[\u5176\u4ed6\u4efb\u610f\u670d\u52a1\u540d]<br \/>\ntype = https<br \/>\nlocal_ip = 127.0.0.1<br \/>\nlocal_port = dddd\uff08\u5ba2\u6237\u7aefnginx\u4e5f\u53ef\u4ee5\u518d\u589e\u52a0\u5176\u4ed6\u7684\u865a\u62df\u4e3b\u673a\uff09<br \/>\nuse_encryption = false<br \/>\nuse_compression = true<br \/>\ncustom_domains =\u00a0<span style=\"color: #ff0000;\">dddd.dddd.ddd<\/span><\/p>\n<p>\u81f3\u6b64\uff0c\u4e3b\u8981\u6280\u672f\u8282\u70b9\u603b\u7ed3\u5b8c\u6bd5\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u8865\u9057\uff1a<\/p>\n<p>1\u3001\u5b89\u88c5lnmp\u524d\u52a1\u5fc5apt-get update\uff0c\u5426\u5219\u8f83\u5927\u51e0\u7387\u5b89\u88c5\u5931\u8d25<\/p>\n<p>2\u3001\u5728\u670d\u52a1\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u65f6\uff0c\u53ef\u901a\u8fc7\u89c2\u5bdffrp\u9762\u677f\u5185\u7684\u8fde\u63a5\u72b6\u51b5\u5206\u6790frp\u662f\u5426\u8fde\u901a\uff0c\u8fdb\u800c\u6392\u9664frp\u6545\u969c\u3002<\/p>\n<p>3\u3001\u901a\u8fc7systemctl\u8bbe\u7f6e\u6811\u8393\u6d3e\u81ea\u52a8\u8fd0\u884cfrpc\u65f6\u51fa\u73b0network unreachable\u3002\u53ef\u901a\u8fc7<\/p>\n<p>Service\u4e0b\u52a0<\/p>\n<p>Restart=0n-failure<\/p>\n<p>RestartSec=5s<\/p>\n<p>\u5c1d\u8bd5\u89e3\u51b3\u3002<\/p>\n<p>\u53e6\u5916\u4e5f\u53ef\u4ee5\u901a\u8fc7\u9009\u4e2d\u6811\u8393\u6d3e\u684c\u9762\u4e2d\u7684\u8bbe\u7f6e\u9996\u9009\u9879\u4e2d\u7684\u7f51\u7edc\u8fde\u901a\u540e\u5b8c\u6210\u542f\u52a8\u9009\u9879\u5c1d\u8bd5\u89e3\u51b3\uff08\u672a\u9a8c\u8bc1\uff09\u3002<\/p>\n<p>4\u3001\u6811\u8393\u6d3e\u642d\u5efa\u7684wordpress\u4f7f\u7528\u4e86\u817e\u8bafcos\u63d2\u4ef6\uff0c\u5728\u4ecehttp\u8f6c\u4e3ahttps\u540e\u9700\u8981\u5c06\u8def\u5f84\u5168\u90e8\u66f4\u65b0\u4e00\u904d\u3002\u53e6\u5916\u81ea\u5b9a\u4e49\u4e3b\u9898\u4e0e\u5176\u4ed6\u63d2\u4ef6\u4e2d\u7684\u90e8\u5206\u76f8\u5173\u8fde\u63a5\u6709\u53ef\u80fd\u9700\u8981\u624b\u52a8\u66f4\u65b0\u624d\u80fd\u6b63\u5e38\u4f7f\u7528\u3002<\/p>\n<p>5\u3001frp\u3001nginx\u4fee\u6539\u540e\u6ce8\u610f\u91cd\u542f\u76f8\u5173\u670d\u52a1<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u7279\u522b\u9e23\u8c22\uff1a<\/p>\n<p>fatedier \uff08https:\/\/github.com\/fatedier\uff09<\/p>\n<p>Raymond Zhou\uff08https:\/\/blog.ray8.cc\/archives\/frpc-frps-nginx-real-ip-https-rewrite-ssl-cert-pure-code.html\uff09<\/p>\n<p>\u2191 \u8fd9\u4f4d\u5927\u4f6c\u7684\u6559\u7a0b\u6781\u4e3a\u8be6\u7ec6\u4e13\u4e1a\uff0c\u4f46\u4e0d\u77e5\u4e3a\u4f55\u6211\u7167\u6b64\u6267\u884c\u4e0b\u6765\uff0c\u4f1a\u51fa\u73b0502\u9519\u8bef\uff0c\u6216\u8005\u8d44\u6e90\u6587\u4ef6\u65e0\u6cd5\u8f7d\u5165\u7684\u95ee\u9898\u3002<\/p>\n<p>\u9e23\u8c22\uff1a<\/p>\n<p>Tony Chyi \u03a6 \u5750\u7b49\u300a\u6211\u4e3a\u6b4c\u72c22\u300b<\/p>\n<p>Lwrless\uff08\u7f51\u7eff\u00a0 \u00a0 t.me\/LWRLESS_FANS\uff09<\/p>\n<p>\u5bd2\u96ea<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f60\u6240\u89c1\uff0c\u4f8b\u884c\u7684\u300a\u6211\u76842019\u6700\u7231\u300b\u4e0e\u300a2020\u65b0\u5e74\u8d3a\u8bcd\u300b\u8fdf\u5230\u4e86\u534a\u4e2a\u591a\u6708\u3002BLOG\u4e5f2\u4e2a\u591a\u6708\u6ca1\u6709\u66f4\u65b0\u3002\u4e3b\u8981\u539f\u56e0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=\/wp\/v2\/posts\/2078"}],"collection":[{"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2078"}],"version-history":[{"count":4,"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=\/wp\/v2\/posts\/2078\/revisions"}],"predecessor-version":[{"id":2102,"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=\/wp\/v2\/posts\/2078\/revisions\/2102"}],"wp:attachment":[{"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bluemountain.pw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}