Redirect IP to domain on nginx

Posted March 1, 2021 439 views

Hello everyone. My recently installed Ghost site is working well, but after the install and domain propagation, I can still access through the public IP.

How can I prevent that from happening? I’ve tried some guides for redirecting the IP to my domain using the nginx config but nothing worked.

I’m currently using two server blocks at the end of default at /etc/nginx/sites-available

server {
return 301;

server {
listen 443;
return 403;

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Configure catch-all server:

server {
    listen      80 default_server;
    server_name "";
    return      444;