5

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?

1 Answer 1

10

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
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.