0

I have two applications on the server, which have different domain names but need to be on the same IP and port. How do I do this with Nginx?

With Apache, I can do this with VirtualHost blocks, but as far as I can tell Nginx server blocks require unique listen lines.

Wige
  • 101
  • 3

1 Answers1

2

Server names in nginx are defined using the server_name directive and determine which server block is used for a given request.

For example:

server {
    listen       80;
    server_name  example.org  www.example.org;
    ...
}

server {
    listen       80;
    server_name  server.org;
    ...
}

There are some server names that are treated specially.

Catch-all server uses the name "_":

server {
        listen       80  default_server;
        server_name  _;
    }

More details can be found here: Nginx Server names