简体   繁体   English

Nginx 反向代理 - 配置子域

[英]Nginx reverse proxy - config for subdomain

  • Hi everyone, I am using vps ubuntu of amazon ec2 for my porject.大家好,我正在为我的项目使用亚马逊 ec2 的 vps ubuntu。 I have 3 project on my vps, they are build on nodejs, so I run it with 3 port: 3000 and 3001 and 80.我的 vps 上有 3 个项目,它们是在 nodejs 上构建的,所以我使用 3 个端口运行它:3000 和 3001 和 80。
  • I bought a domain in godaddy, the url like: abc.def, now, when I go to browser and type abc.def:3000 , abc.def:3001 , abc.def , it run ok with 3 projects above.我在 godaddy 买了一个域名,url 像:abc.def,现在,当我 go 到浏览器并输入abc.def:3000abc.def:3001abc.def时,运行正常。

    The question is问题是

    How I can config it to when I type输入时如何将其配置为

  • abc.def -> it run project port 3000 abc.def -> 它运行项目端口 3000

  • site.abc.def -> it run portject port 3001 site.abc.def -> 它运行 portject 端口 3001
  • site2.abc.def -> it run portject port 80 site2.abc.def -> 它运行 portject 端口 80

Thank for your comment here感谢您在这里的评论

You need to create 2 sub-domains (site.abc.def and site2.abc.def) and create a nginx configuration file with all the 3 domains with different server directives for each site.您需要创建 2 个子域(site.abc.def 和 site2.abc.def)并创建一个 nginx 配置文件,其中包含所有 3 个域,每个站点具有不同的服务器指令。 Use proxy_pass and direct it as per your requirement.使用 proxy_pass 并根据您的要求定向它。

Edit: Something similar as in the following answer Nginx multiple server编辑:类似于以下答案Nginx 多服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM