本文介绍了Nginx中不同IP上的不同域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我想使用两个具有不同IP地址的不同域

I want to use two different domains with different IP addresses, for example

domain1.com - 12.34.56.78 
domain2.com - 98.76.54.32

我在Linux操作系统上使用 nginx .我应该在我的nginx.conf中添加什么?

I am using nginx on Linux OS. What should I add in my nginx.conf?

推荐答案

您必须使用server块创建两个虚拟主机.

You have to create two virtual hosts using server block.

让我们假设/var/www包含domain1.comdomain2.com目录以及任何HTML页面,CGI脚本,...

Let's suppose /var/www contains domain1.com and domain2.com directories with whatever HTML pages, CGI scripts, ...

server {
  listen          12.34.56.78:80;
  server_name     domain1.com

  index           index.html;
  root            /var/www/domain1.com
}

server {
  listen          98.76.54.32:80;
  server_name     domain2.com;

  index           index.html;
  root            /var/www/domain2.com
}

这篇关于Nginx中不同IP上的不同域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 06:13