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

How to stop domains from pointing to my server IP address and duplicating my site using nginx

· 52CE 我爱测

I recently created an Ubuntu server and installed LEMP stack after which I hosted my website on the server using WordPress. But after sometime, I notices some domains ranking in Google and loading my website. Is there any way thr…

问题原文

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

I recently created an Ubuntu server and installed LEMP stack after which I hosted my website on the server using WordPress.

But after sometime, I notices some domains ranking in Google and loading my website.

Is there any way through which I can stop them from doing this?

Previously, I never faced such issue.

For reference: My main domain: https://droidmaze.com

Other domains (not mine) pointing to my server I.P.:

http://tirtadji.com/
http://www.pisonlifetree.com

I am concerned that this can penalize my website for duplicate content.

已采纳解答

原帖链接 · Tom Brossman · CC BY-SA 4.0

To improve security, prevent host header attacks, and preserve your search rankings, here is what I recommend:

No default site

Simply drop all traffic not matching your genuine website. Before using the below config, execute the following example command on your server to generate self-signed "dummy" certificates which are necessary for responding to HTTPS requests.

mkdir /etc/ssl/dummy && openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/ssl/dummy/dummy.key -out /etc/ssl/dummy/dummy.crt

Now use the following two server blocks for your default site configuration.

server {
    listen [::]:80 default_server;
    listen      80 default_server;
    return 444;
}

server {
    listen     [::]:443 ssl http2 default_server;
    listen          443 ssl http2 default_server;
    ssl_certificate           /etc/ssl/dummy/dummy.crt;
    ssl_certificate_key       /etc/ssl/dummy/dummy.key;
    return 444;
}

Reload Nginx and it will drop all the copycat site connections.

Prevent framing

Somewhere in your genuine site's server block, add the following header to prevent someone embedding your site as a frame / iframe at their domain name.

add_header X-Frame-Options "SAMEORIGIN";

Canonical URLs

In the <head> section of every page, add a canonical URL link element. If every page has something like <link rel="canonical" href="https://www.your-site.com/your-page/"> then even if someone copies your site at their domain name, search engines recognise your site as the original.

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

资料来源与适用范围

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

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

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