Different Domains on Different IP's in Nginx?

2019-05-04 07:06发布

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

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

标签: nginx
1条回答
Evening l夕情丶
2楼-- · 2019-05-04 07:36

You have to create two virtual hosts using server block.

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
}
查看更多
登录 后发表回答