Inside /etc/nginx/sites-available, I have a config file example with the following configuration:
server { listen 443 ssl; server_name php1.example.com php2.example.com; ssl_certificate /etc/nginx/ssl/example.crt; ssl_certificate_key /etc/nginx/ssl/example.key; root /var/www/html/example/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust the PHP version if needed fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } error_log /var/log/nginx/example_error.log; access_log /var/log/nginx/example_access.log; } server { listen 80; server_name admin.php1.example.com; root /var/www/html/example/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust the PHP version if needed fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } error_log /var/log/nginx/example_error.log; access_log /var/log/nginx/example_access.log; } This serves a PHP website which is setup in a way to connect to different databases for different subdomains. I am using Cloudflare and could not setup SSL for the multi-level subdomain admin.php1.example.com. I have pointed php1.example.com, php2.example.com, php3.example.com and admin.php1.example.com to my server's IP, but have not included php3.example.com in my config file.
The issue is, when I go to php3.example.com in my browser, it loads up the website even though it is not configured in the config file. I cannot figure out which config file is being used to serve the website.
Since it was working as intended for the other subdomains, I ignored it.
Until now, when I had to setup a Node.js project on the same server. I wrote another config file node-project.conf with the following configuration:
server { listen 80; server_name node.example.com; # location / { # proxy_pass http://localhost:4000; # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection 'upgrade'; # proxy_set_header Host $host; # proxy_cache_bypass $http_upgrade; # } location / { root /usr/share/nginx/html; index index.html index.htm; } } I am trying to serve NGINX's default welcome page to test if my new subdomain node.example.com is correctly pointed to my IP. But when I visited the subdomain in my browser, I got served the same PHP website that was being served for php3.example.com.
I am new to this, but am passionate about server administration. I want to fix this issue as well as understand what is happening behind the scene, so I can become a better admin.
I am also new to Server Fault. I have tried my best to make the question as descriptive as possible, but if anybody wants additional information regarding anything, please let me know.
In sites-available, I have default config with following configuration:
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; server_name _; location / { try_files $uri $uri/ =404; } }