0

I am using Debian, Nginx

I am a little novice in nginx

I have purchased a VPS Server, when I access my IP 33.xxx.xxx.xxx.xx through my browser either as https:// IP or http:// IP my website content is displayed, as if I had entered my domain.com in the browser.

In this case I would like to display some blocking warning like 403 Forbidden or if you can show me how to redirect the visitor who accesses the IP to a blank page.

Thanks

1
  • You do realise that the connection to your website is by ipaddress:port ? Simplisticly, the domain name is an index at the Domain Name Servers to obtain the ipaddress. Commented Sep 20, 2022 at 0:22

1 Answer 1

0

You need to use a server_name www.example.com; directive in your server block in the NGINX config, instead of server_name _; which matches everything.

You need two server blocks. One with a server_name matching your domain name, that serves the proper website. And another with server_name _; as a catch all that serves a error page.

See here: https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .