googleで自分のドメインを検索すると、Googleがhttpsを愛しているため、私のウェブサイトからいくつかのhttps URLが表示されますが、特にhttps/sslバージョンのインデックスを作成したくないためです。Googleのhttps URLのインデックス登録を防止するにはどうすればよいですか?
これを避けるには、全世界がhtaccess経由で解決策を書いていますが、ほとんどの場合はnginxを使用してください。 (余分なロボットで)
RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^robots.txt$ robots-deny-all.txt [L]
ロボットコンテンツ:
User-agent: *
Disallow:/
がどのようにnginxの書き換えルールを経て、これを行うにはどのようにこの問題を解決するには?
ありがとうございます。
JUST加(私の/etc/nginx/sites-availble/somedomain.conf):あなたの中
server {
server_name somedomain.com www.somedomain.com;
listen 100.10.10.10;
root /home/somedomain/public_html;
index index.php index.html index.htm;
access_log /var/log/virtualmin/somedomain.com_access_log;
error_log /var/log/virtualmin/somedomain.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/somedomain/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/somedomain/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
##
# cache client
##
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 30d;
}
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?q=$uri&$args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location = /robots.txt {
if ($scheme = https) {
rewrite^/robots-deny-all.txt permanent;
}
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
listen 100.10.10.10:443 ssl;
ssl_certificate /home/somedomain/ssl.cert;
ssl_certificate_key /home/somedomain/ssl.key;
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
}
私/etc/ngonx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 128;
client_max_body_size 100M;
client_body_buffer_size 16k;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 180;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
前回のコメントをお詫び申し上げます。ありがとうございました。以前のコメントをお詫び申し上げます。準備が整う前に私は誤って送ってきました。質問に私のサーバーブロックを追加しました。まだlinsten 443 sslを追加する必要があるかどうか教えてください。サーバーブロックの始めに、私はすでにデフォルトで既にそれを持っていますから? ....そしてどこでadd_headerを追加すればいいですか? – hercules
私は混乱しています、最初にあなたは私の混乱している、私の設定を使用してadd_header X-Robに追加...(nginx.confファイルサーバーブロックは存在しませんが、各仮想ホストに存在します... nginx-sites-availble/somedomain.confにあります)もう一度ありがとうございます。 – hercules
私が 'nginx.conf'と言うとき、その特定のファイルである必要はありません。私はちょうどあなたのnginx設定で言うつもりだった。どこにでも保管してください。 'sites-enabled'を使用している場合は、 – borislemke