大网数据广告活动
网站运营与故障问答

Is it possible for a hacker to point another domain at my domain?

· 52CE 我爱测

Recently when I search my website on google, I find that another domain's description is identical to my domain. I'm terrified and try to understand the security breaches of my website as much as possible. I clicked on the link o…

问题原文

原帖链接 · LittleTeemo · CC BY-SA 4.0

Recently when I search my website on google, I find that another domain's description is identical to my domain. I'm terrified and try to understand the security breaches of my website as much as possible. I clicked on the link of this fake website and it turned out to be 'Your connection is not private'. When I search this fake website's domain through whois, it shows another company's info.

My website is built with react, hosted on a VM with docker and nginx.

I found this fake website today, just after I tried implementing google analytics and google tag manager on my website yesterday.

Can you tell me what's going on now please? And how I can prevent any security issues?

My nginx config in default.conf file

server {
    listen 80;

    server_name www.mywebsite.com; 
    rewrite ^(.*)$ https://$host$1; 

    location / { 
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    } 
    error_page 404 /index.html;
    location = / {
        root /usr/share/nginx/html;
        internal;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

# nginx docker container, ssl config
server {
    listen 443 ssl;

    server_name www.mywebsite.com;
    root html;
    index index.html index.htm;
    ssl_certificate /path/to/ssl.pem; 
    ssl_certificate_key /path/to/ssl.key;   
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    } 
}

Now I know I need to setup the default server

80 default server works fine

I'm not going to list it 80 default server here, more see accepted answer.

443 ssl default server, which doesn't work for me :(
server {
    listen 443 ssl default_server;
    ssl_certificate path-to-pem;
    ssl_certificate_key path-to-key;
    server_name _;

    # Everything is a 404 Not found
    location / {
        return 404;
    }
}


I still don't know how to setup the 443 ssl default server block for nginx, please let me know if you have any idea.

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

Anybody can point any domain to your web server. When this happens it is usually not an attack or a security threat. It is often because some other website used to use your IP address or because some other website is misconfigured.

In your case some other domain is pointing to your server. Your server is issuing a redirect for that domain from HTTP to HTTPS. The the HTTPS request fails because the host name doesn't match the SSL certificate. There are better ways to handle this.

You can use your webserver configuration to show an appropriate error message for unrecognized domain names. Every HTTP/HTTPS request is made to your server with the host name included as part of the request. Your webserver can use that information to show an error.

Under Nginx and Apache this is done by configuring an extra "catch all" virtual host to handle unknown domains. This default catch-all needs to come first in your configuration before the more specific virtual host for your domain name.

To serve a 404 error rather than redirecting unknown domain names to HTTPS you would use configuration like this at the top of nginx's default.conf:

# The default server:
server {
    listen       80 default_server;
    server_name  localhost;

    # Everything is a 404 Not found
    location / {
        return 404;
    }
}

Source: https://stackoverflow.com/questions/7526996/nginx-how-to-always-return-a-custom-404-page-for-the-default-host which has examples with a custom error document.

Unknown domains will use this virtual host because it is listed first in the file. Domains that match a specific server_name will use its virtual host. To that end you should update the server_name to something like the following so that the bare domain works as well as ALL subdomains.

server_name example.com *.example.com; 

Source: https://serverfault.com/questions/718801/server-aliases-on-nginx

You could consider using a default virtual host for the listen 443 ssl block as well. That is a bit less important because unknown domains get a certificate error. Although any client that ignores that error still gets a copy of your site at some other domain.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-08-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。