简体   繁体   English

是否可以在 nginx 上拥有具有不同路由的相同 IP 的 2 个子域?

[英]Is it possible to have 2 sub-domains of the same IP with different routes on nginx?

Let's say I have mon.example.com and prom.example.com, both of them share the same IP.假设我有 mon.example.com 和 prom.example.com,它们都共享相同的 IP。 Is it possible to route each of them to different services or content?是否可以将它们中的每一个路由到不同的服务或内容?

Yes, it is possible, you can create two different server blocks and config your cases.是的,有可能,您可以创建两个不同的服务器块并配置您的案例。

 server {
    server_name prom.example.com;
    access_log logs/domain1.access.log main;

    root /var/www/domain1.com/htdocs;
  }

for the other为对方

 server {
    server_name mon.example.com;
    access_log  logs/domain2.access.log main;

    root /var/www/domain2.com/htdocs;
  }

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

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