4

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

domain1.com - 12.34.56.78 
domain2.com - 98.76.54.32

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

4

1 回答 1

9

您必须使用block创建两个虚拟主机。server

让我们假设/var/www包含任何 HTML 页面、CGI 脚本、...的目录domain1.com和目录domain2.com

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
}
于 2012-07-16T06:15:30.943 回答