text: (window.webpackJsonp=window.webpackJsonp||[]).push([[25],{541:function(s,a,t){"use strict";t.r(a);var n=t(3),r=Object(n.a)({},(function(){var s=this,a=s.$createElement,t=s._self._c||a;return t("ContentSlotsDistributor",{attrs:{"slot-key":s.$parent.slotKey}},[t("div",{staticClass:"custom-block tip"},[t("p",[s._v("栈外技术，是指栈内技术的上下游，领域外的相关专业知识，包括但不限于服务端技术、运维、CDN、测试，甚至 UI 设计、产品设计等等，扩展你栈内技术的周围领域，充分理解你的工作在整个技术研发体系中处于怎样的环节。工作之余多投入一份精力，把其他栈外技术不断纳入到你的知识体系中来，建立栈外能力。前端想要做的深入，往往会涉及到缓存、模板渲染、用户体验等知识，没有相当的栈外技术积累，你很难为自己的团队争取到足够的话语权。")])]),s._v(" "),t("p",[s._v("想想自己在公司的时候，基本都是写业务，做前端相关的工作，但对于其他方面是涉猎比较少，或者基本没有的。又再想想之前面试的时候，面试官也会问一些栈外问题，比如说你们公司的代码是如何发布部署的，这时候的我是一脸懵逼的。这就使得我想要懂得如何部署代码，以下是折腾的过程，记录一下。")]),s._v(" "),t("h2",{attrs:{id:"云服务器"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#云服务器"}},[s._v("#")]),s._v(" 云服务器")]),s._v(" "),t("p",[s._v("云服务器的购买，可以选择阿里云和腾讯云，我之前并没有仔细地去比价两者的价格如何，想着就是用来玩玩如何部署的，也就没有多在意这些，毕竟也不是长期购买，花不了几个钱，就选了腾讯云。至于选购什么配置的服务器，就看个人了。买完之后，还要做一些认证等，需要等待一两天的时间。对了，我还买了一个域名，但是后来发现备案的手续挺麻烦的，想着之后用 ip 地址也可以访问，就没有去管了。")]),s._v(" "),t("h3",{attrs:{id:"ssh-登录"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#ssh-登录"}},[s._v("#")]),s._v(" ssh 登录")]),s._v(" "),t("p",[s._v("有了服务器后，你需要登录。那要怎么登录呢，这里介绍一个简单的方法。")]),s._v(" "),t("h3",{attrs:{id:"本地生成-ssh-公钥"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#本地生成-ssh-公钥"}},[s._v("#")]),s._v(" 本地生成 ssh 公钥")]),s._v(" "),t("p",[s._v("首先，你需要确认自己是否已经拥有秘钥。默认情况下，用户的 SSH 秘钥存储在~/.ssh 目录下。进入该目录并列出其中内容，便可以快速确认自己是否已拥有秘钥:")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("# 本地\n$ cd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("~")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh\n$ ls\nconfig      id_rsa      id_rsa"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("pub  known_hosts\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br")])]),t("p",[s._v("我们需要寻找一对以 id_dsa 或 id_rsa 命名的文件，其中一个带有 .pub 扩展名。.pub 文件是你的公钥，另 一个则是私钥。如果找不到这样的文件或者根本没有 .ssh 目录， 你可以通过运行 ssh-keygen 程序来创建它们。")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("# 本地\n$ ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("keygen\nGenerating "),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("public")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("private")]),s._v(" rsa key pair"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("\n# 输入 enter 键\nEnter file "),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("in")]),s._v(" which to save the "),t("span",{pre:!0,attrs:{class:"token function"}},[s._v("key")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("(")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("Users"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("laohan"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("id_rsa"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(")")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v("\nCreated directory "),t("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/Users/laohan/.ssh'")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("\n# 两次输入密码\nEnter "),t("span",{pre:!0,attrs:{class:"token function"}},[s._v("passphrase")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("(")]),s._v("empty "),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("for")]),s._v(" no passphrase"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(")")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v("\nEnter same passphrase again"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v("\nYour identification has been saved "),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("in")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("Users"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("laohan"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("id_rsa"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("\nYour "),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("public")]),s._v(" key has been saved "),t("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("in")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("Users"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("laohan"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("id_rsa"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("pub"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("\nThe key fingerprint is"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("SHA256")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v("XhI9aeGsVJklGyUTvNu"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("6")]),s._v("ABzOZdZL2"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("y5aMOVQa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("ZvI laohan@bogon\nThe key's randomart image is"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("[")]),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("RSA")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("2048")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("]")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("         "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("O")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("*")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("    "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("         "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("X")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("   "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("        o "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("O")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("o o  "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("       "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),s._v("   "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("      o "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("S")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("*")]),s._v("o"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("*")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("  "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("       "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("*")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("o   "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("        o "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("E")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("  "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("         "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v(" o"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("*")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("  "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("         "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("o"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),s._v("o"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("|")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("[")]),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("SHA256")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("]")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("--")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br"),t("span",{staticClass:"line-number"},[s._v("6")]),t("br"),t("span",{staticClass:"line-number"},[s._v("7")]),t("br"),t("span",{staticClass:"line-number"},[s._v("8")]),t("br"),t("span",{staticClass:"line-number"},[s._v("9")]),t("br"),t("span",{staticClass:"line-number"},[s._v("10")]),t("br"),t("span",{staticClass:"line-number"},[s._v("11")]),t("br"),t("span",{staticClass:"line-number"},[s._v("12")]),t("br"),t("span",{staticClass:"line-number"},[s._v("13")]),t("br"),t("span",{staticClass:"line-number"},[s._v("14")]),t("br"),t("span",{staticClass:"line-number"},[s._v("15")]),t("br"),t("span",{staticClass:"line-number"},[s._v("16")]),t("br"),t("span",{staticClass:"line-number"},[s._v("17")]),t("br"),t("span",{staticClass:"line-number"},[s._v("18")]),t("br"),t("span",{staticClass:"line-number"},[s._v("19")]),t("br"),t("span",{staticClass:"line-number"},[s._v("20")]),t("br"),t("span",{staticClass:"line-number"},[s._v("21")]),t("br"),t("span",{staticClass:"line-number"},[s._v("22")]),t("br"),t("span",{staticClass:"line-number"},[s._v("23")]),t("br"),t("span",{staticClass:"line-number"},[s._v("24")]),t("br"),t("span",{staticClass:"line-number"},[s._v("25")]),t("br")])]),t("p",[s._v("首先 ssh-keygen 会确认密钥的存储位置(默认是 .ssh/id_rsa)，然后它会让你重复一个密码两次，如果不想在使用公钥的时候输入密码，可以留空。")]),s._v(" "),t("p",[s._v("公钥看起来是这样的:")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("$ cat "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("~")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("id_rsa"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("pub\nssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc4xbJxlMTgiE13I1RL6IsG44"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("3")]),s._v("CQc8Ft03eZnYfNrPVeQIf9r9kTuArSiUnY"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("BHXn3mrQ5i"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("5")]),s._v("AGi"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("alys94Pum2dZ68QtlY1QdEl4iN3LFXUkbJc"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("M0rllaDGH5JNtfk5imVqDo8Tn7aJsFd4IXbwrl3Euf"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("ccOb"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("s92RHwzbSRx37tP9pLF9ujfL0UXfg3"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("DmRJMJT7iN3OiJxfuF5k8KSySEz"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("+")]),s._v("YbhQoNeySuvVPeRHG"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("U6xOGcpzNjQIPApGsuFdLT5R"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("5")]),s._v("x15W7SrC"),t("span",{pre:!0,attrs:{class:"token comment"}},[s._v("//XWuIQMmlVTW2X0YH+5NjT0nlLVWxS4drtRCS66JXtRceVqs5H5InbsLfALfTPyIkZ4t laohan@bogon")]),s._v("\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br")])]),t("p",[s._v("具体可以参考这里 https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent")]),s._v(" "),t("h3",{attrs:{id:"云服务器配置"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#云服务器配置"}},[s._v("#")]),s._v(" 云服务器配置")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("$ cd\n$ mkdir "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("&&")]),s._v(" chmod "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("700")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh\n$ touch "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("authorized_keys "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("&&")]),s._v(" chmod "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("600")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("authorized_keys\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br")])]),t("p",[s._v("接下来，把开发者的 SSH 公钥添加到这个用户的 authorized_keys 文件中。")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("$ vim "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("ssh"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("authorized_keys\n# 把之前生成是 "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("SSH")]),s._v(" 公钥添加到文件尾部\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br")])]),t("h3",{attrs:{id:"本地-config-配置"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#本地-config-配置"}},[s._v("#")]),s._v(" 本地 config 配置")]),s._v(" "),t("p",[s._v("现在已经可以通过 ssh 无密码的方式登录云服务器了")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("ssh root@"),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("IP")]),s._v("\n# "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("IP")]),s._v(" 为 云服务器的 "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("IP")]),s._v(" 地址\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br")])]),t("p",[s._v("如上，是不是感觉很方便。可是这种方式，你还是需要知道云服务器的 ip 地址，那有没有更省脑的方式呢？\n有的，在~/.ssh 下的 config 文件中添加以下代码即可")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("Host hostname # hostname 为你想要设置的别名\nHostName "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("IP")]),s._v(" # "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("IP")]),s._v(" 为云服务器的 "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("IP")]),s._v(" 地址\nUser root\nIdentitiesOnly yes\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br")])]),t("p",[s._v("之后，就可以通过如下的方式登录到云服务器了")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("ssh hostname # hostname 为你刚才设置的名称\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br")])]),t("h2",{attrs:{id:"代码"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#代码"}},[s._v("#")]),s._v(" 代码")]),s._v(" "),t("p",[s._v("个人理解，云服务器也就是一台机器，你的代码在自己的电脑怎么跑，到了云服务器还是怎么跑，只是运行的环境不一样了，需要做一些配置。\n现在，我们已经有了云服务器了，接下来就是如何把我们能在本地跑起来的代码部署在服务器上。\n我采用的方式比较简单，就是直接在把我本地的代码 push 到 github 上面，然后在服务器那里用 git clone，把代码下载到本地。github 地址 koa-demo。又或者你可以把代码在本地打包后，利用 scp 远程复制。")]),s._v(" "),t("h2",{attrs:{id:"云服务器设置-nginx"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#云服务器设置-nginx"}},[s._v("#")]),s._v(" 云服务器设置 nginx")]),s._v(" "),t("p",[s._v("nginx，是运维同学经常打交道的。你可能听过反向代理、负载均衡等名词，这都是跟 nginx 有关的。")]),s._v(" "),t("h3",{attrs:{id:"安装-nginx"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#安装-nginx"}},[s._v("#")]),s._v(" 安装 nginx")]),s._v(" "),t("p",[s._v("我的服务器是 centos 系统的，所以安装的方式如下")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("yum install "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("y nginx\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br")])]),t("h3",{attrs:{id:"conf-配置"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#conf-配置"}},[s._v("#")]),s._v(" conf 配置")]),s._v(" "),t("p",[s._v("对于 nginx 来说，主要就是 nginx.cof 这份配置文件，位于/etc/nginx 路径下，下面就进行修改")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("cd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("etc"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("nginx\nvi nginx"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("conf\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br")])]),t("p",[s._v("修改后的内容如下")]),s._v(" "),t("p",[t("img",{attrs:{src:"https://vkceyugu.cdn.bspapp.com/VKCEYUGU-aliyun-umybkfmeehmg0383ca/9902d8a0-4856-11eb-b997-9918a5dda011.png",alt:"部署"}})]),s._v(" "),t("p",[s._v("注意：确保红色圈中的 1 部分没有被注释，圈中的 2 部分注释。\n这样做的目的是为了如果之后需要添加多个 server 的话，都在 nginx.conf 文件改，就不容易维护了。 接下来，添加我们这次需要的跟 nginx 相关的文件")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("cd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("etc"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("nginx"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("conf"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("d\ntouch koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("conf\nvi koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("conf\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br")])]),t("p",[s._v("然后，把以下内容 copy 到 koa-demo.con 中并保存")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("upstream koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n  server "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("127.0")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v(".0")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v(".1")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("3000")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n\nserver "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n  listen "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("80")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v("\n  location "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n    proxy_pass http"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v("\n  "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br"),t("span",{staticClass:"line-number"},[s._v("6")]),t("br"),t("span",{staticClass:"line-number"},[s._v("7")]),t("br"),t("span",{staticClass:"line-number"},[s._v("8")]),t("br"),t("span",{staticClass:"line-number"},[s._v("9")]),t("br"),t("span",{staticClass:"line-number"},[s._v("10")]),t("br")])]),t("p",[s._v("之后，使用下面的命令")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("nginx "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("t\n# 用来测试你的配置文件是否 ok\n\nnginx "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("s reload\n# 重新加载配置文件\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br")])]),t("p",[s._v("没意外的话，这个时候在浏览器中输入你的云服务器 ip 地址，就可以看到效果了。 等等，你说你的浏览器没反应。不要慌，这是因为你的代码还没运行呢")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("# 我的代码克隆在这里，你的路径可能跟我的不同\ncd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("opt"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo\nnpm start\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br")])]),t("p",[s._v("这时候再刷新页面，ok 了，大功告成。\n接着，你可能就想给自己加个鸡腿庆祝一下，然后就退出了云服务器，跑去吃饭了。吃完饭回来，再次刷新浏览器，我了个去，怎么又没内容了。 为什么会这样呢？\n这是因为你打开的方式不对，也就是启动代码的方式不对，你可以看看 packagek.json 的内容，npm start 其实就是执行 node index.js 。当你这边退出了，这个进程也就结束了，想想在你的本地是不是也这样，你在你的终端运行，打开浏览器是没有问题的，退出终端，再刷新页面，就出问题了。\n那这个问题要如何解决呢？呃，如果你之前有接触过 node，那应该就听过 pm2 这个词了。是的，没错，接下来我们就用这个 pm2 解决我们的问题。")]),s._v(" "),t("h3",{attrs:{id:"pm2-运行程序"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#pm2-运行程序"}},[s._v("#")]),s._v(" pm2 运行程序")]),s._v(" "),t("p",[s._v("这里就不多介绍了，看文档会更快了解。 那接下来怎么跑呢，你可以看到 package.json 里面的 script 还有个命令，就是 pm2，这个就是我之前已经添加好了，用 pm2 来启动程序的命令。具体如下：")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("# 先登录到云服务器\nssh hostname\n# 进入代码目录\ncd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("opt"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo\n# run\nnpm run pm2\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br"),t("span",{staticClass:"line-number"},[s._v("6")]),t("br")])]),t("h2",{attrs:{id:"docker-部署"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#docker-部署"}},[s._v("#")]),s._v(" Docker 部署")]),s._v(" "),t("p",[s._v("首先，我们需要在我们的 koa-demo 中添加 Dockerfile 和.dockerignore。我已经在代码中添加好了，你可以直接简单地复制到你的项目中。至于其中的那些命令代表什么意思，就不多解释了。你看完阮老师的那篇文章，多少有点了解了。或者你可以 docker COMMAND -h 获取各个命令的使用。")]),s._v(" "),t("h3",{attrs:{id:"编译镜像"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#编译镜像"}},[s._v("#")]),s._v(" 编译镜像")]),s._v(" "),t("p",[s._v("进入到我们的代码目录，利用 docker build 命令，编译出我们需要的镜像文件，然后用 docker run，运行容器")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("cd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("opt"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo\ndocker build "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("t koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("\ndocker run "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("d "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("p "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("7000")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("3000")]),s._v(" koa"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br")])]),t("p",[s._v("这里，我用本地的 7000 端口映射容器的 3000 端口。\n这个时候，你可以使用一下命令，看是否正确运行")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("curl "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("i localhost"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("7000")]),s._v("\n\n# 应该会返回如下结果\n"),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("HTTP")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("1.1")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("200")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("OK")]),s._v("\nContent"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("Type"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v(" text"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("plain"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v(" charset"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=")]),s._v("utf"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("8")]),s._v("\nContent"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("Length"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("30")]),s._v("\nDate"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v(" Mon"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("02")]),s._v(" Jul "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("2018")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("12")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("12")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("26")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token constant"}},[s._v("GMT")]),s._v("\nConnection"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),s._v(" keep"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("alive\n\nIt's success"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" congratulation"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("!")]),s._v("\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br"),t("span",{staticClass:"line-number"},[s._v("6")]),t("br"),t("span",{staticClass:"line-number"},[s._v("7")]),t("br"),t("span",{staticClass:"line-number"},[s._v("8")]),t("br"),t("span",{staticClass:"line-number"},[s._v("9")]),t("br"),t("span",{staticClass:"line-number"},[s._v("10")]),t("br")])]),t("p",[s._v("现在，我们的容器已经跑起来了，你可以想试试直接在浏览器输入 ip:port 这样的形式是否可以访问，等你输入之后，你会发现是没有反应的。\n为什么呢，不要急，我们还没有添加 nginx 配置呢。")]),s._v(" "),t("div",{staticClass:"language-js line-numbers-mode"},[t("pre",{pre:!0,attrs:{class:"language-js"}},[t("code",[s._v("cd "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("etc"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("nginx"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("conf"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("d\nvi docker"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("conf\n\n# 写入以下内容\nupstream docker"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n  server "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("127.0")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v(".0")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v(".1")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("7000")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n\nserver "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n  listen "),t("span",{pre:!0,attrs:{class:"token number"}},[s._v("7000")]),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v("\n  location "),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v(" "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n          proxy_pass http"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v(":")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("/")]),s._v("docker"),t("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("demo"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(";")]),s._v("\n  "),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n"),t("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n")])]),s._v(" "),t("div",{staticClass:"line-numbers-wrapper"},[t("span",{staticClass:"line-number"},[s._v("1")]),t("br"),t("span",{staticClass:"line-number"},[s._v("2")]),t("br"),t("span",{staticClass:"line-number"},[s._v("3")]),t("br"),t("span",{staticClass:"line-number"},[s._v("4")]),t("br"),t("span",{staticClass:"line-number"},[s._v("5")]),t("br"),t("span",{staticClass:"line-number"},[s._v("6")]),t("br"),t("span",{staticClass:"line-number"},[s._v("7")]),t("br"),t("span",{staticClass:"line-number"},[s._v("8")]),t("br"),t("span",{staticClass:"line-number"},[s._v("9")]),t("br"),t("span",{staticClass:"line-number"},[s._v("10")]),t("br"),t("span",{staticClass:"line-number"},[s._v("11")]),t("br"),t("span",{staticClass:"line-number"},[s._v("12")]),t("br"),t("span",{staticClass:"line-number"},[s._v("13")]),t("br"),t("span",{staticClass:"line-number"},[s._v("14")]),t("br")])]),t("p",[s._v("记得用 nginx -t 来测试你的 conf 是否 ok， 然后 nginx -s reload 重新加载一下。\n这个时候，你就可以用 IP:Port（这里的 Port 是上面的 listen 的端口） 的形式访问了。\n假如，你这个时候还是没法访问的话，有可能是你的安全组设置的问题，设置一下即可。")]),s._v(" "),t("div",{staticClass:"custom-block tip"},[t("p",[s._v("作者：流汗去 "),t("br"),s._v("\n链接：https://juejin.im/post/5b45f4f7f265da0fab400502 "),t("br"),s._v("\n来源：掘金")])])])}),[],!1,null,null,null);a.default=r.exports}}]);