How to configure Nginx for calls to not hosted domain names

Is it possible to configure through HestiaCP (web ui or cli) the behaviour of nginx when someone call to your server IP?

Let me expose my case (i’ve read that some other people have this problem with nginx):

  • i have a server hosting a unique domain name ( and its own unique IP
  • but someone has set just MY IP to his domain name (… using its DNS zones outside my server, obviously (i’ve not understood still if it has any use for the owner of that domain name)
  • so my server (nginx/hestia) is responding with a “sane” 200 if you type that domain name ( in browser or call it with a terminal PING, curiously just as it was an “alias” of
  • i would like to be able to configure nginx to return a 404 code for any other domain name not configured by me through Hestia
  • i’ve searched on internet and discovered that i can manually configure nginx files for domains, but i unknow if this settings will remain after the next Hestia update… i suppose it don’t.

So, any clue or suggestion?

If the domain has not been configured with in Hestia is should show by default:

Just add return 404 to /etc/nginx/conf.d/ip.conf

1 Like

Many thanks!! After search by some minutes on internet and some attempts i got it run with a simple configuration. I want to share it here for others.

You must edit the nginx config file for your IP:

nano /etc/nginx/conf.d/

And then set this content (replace by your server IP):

server {
    listen default;
    server_name  _;
    return 404;

server {
    listen ssl http2;
    server_name _;
    ssl_certificate      /usr/local/hestia/ssl/certificate.crt;
    ssl_certificate_key  /usr/local/hestia/ssl/certificate.key;
    return 404;

Indeed, to activate this new settings, restart Nginx service:

sudo service nginx restart

And voilà!! :slight_smile:


Isn’t that file going to be re-written after an hestia update?

No, that file will not be touched.