1

I have an nginx server running that has multiple projects inside the sites-enabled. The problem comes when trying to access and nonexistent project url, nginx will render the 1st available.

Example, I have a server with the IP 111.222.333.444 and NGINX with those projects:

  1. aaa.test.com
  2. bbb.test.com
  3. ccc.test.com

I am creating now a new domain that is ddd.test.com and points to the 111.222.333.444 When trying to access ddd.test.com, my browser will open aaa.test.com

Any idea why?

In my nginx project config I have for aaa.test.com

 server {
    listen                  80;
    server_name             aaa.test.com;
    access_log              /usr/local/nginx/logs/aaa.access.log;
    error_log               /usr/local/nginx/logs/aaa.error.log;
    root                    /var/www/aaa/web;


    client_max_body_size    60M;

    location / {
            index app.php;
            if (-f $request_filename) {
            break;
            }
            rewrite ^(.*)$ /app.php last;
    }


    ## Parse all .php file in the /var/www directory
    location ~ \.php$ {
            fastcgi_split_path_info         ^(.+\.php)(.*)$;
            fastcgi_pass                   127.0.0.1:9001;
            fastcgi_index                   index.php;
            fastcgi_param                   SCRIPT_FILENAME  $request_filename;
            include                         fastcgi_params;
    }
}
Milos Cuculovic
  • 423
  • 3
  • 8
  • 22

1 Answers1

2

You need to make a separate default virtual host that does whatever you want:

server {
    listen 80 default_server;

    return 404;
}
Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63