NGINIX Security / Redirect Help

I have discovered that – for some reason – another domain name is pointing to my website. I’m unsure why this is, but I assume it’s malicious and would like to prevent this from happening. It seems like the best fix is a 301 redirect but I’m not used to nginx and haven’t had any success trying to figure this out on my own.

For instance, if my website is “,” then “” is pointing to “”.

To pseudocode a fix, I believe I need something in the nginx config file to the effect of:

server {
(if incoming traffic != from {
301 redirect to$uri}

I do not know how to implement this. Any tips?

Ubuntu 20.04
Ghost 5.42.0

Update your Nginx Configuration something like that…

sudo nano /etc/nginx/sites-available/default

Now you can add a new server block to catch any unauthorized traffic and redirect it to your main domain

Here’s an example set of script…

server {
    listen 80 default_server;
    server_name _;

    if ($host !~ ^(coolblog\.com)$ ) {
        return 301$request_uri;

    # Other configuration directives go here...

Save it and test it 

1 Like

before applying above changes it’s a good practice to test the Nginx configuration to make sure there are no syntax errors.

sudo nginx -t

once done check manually use browser developer tools to inspect network requests and redirects or use any online tool like This can help you to get Bulk url detail redirection chain and its status code.

1 Like