Here are the configurations to prevent search engines (Google, Bing, etc.) from indexing all sites on your server using global configuration for both web servers Apache and Nginx:
Prevent search engines indexing in Apache
Add the following line in httpd.conf or apache2.conf:
# Global no-index setting
Header always set X-Robots-Tag "noindex, nofollow, noarchive"
Prevent search engines indexing in Nginx
Add the following line in nginx.conf in the http bloc :
http {
# Global no-index setting
add_header X-Robots-Tag "noindex, nofollow, noarchive, nosnippet, noimageindex" always;
# ... other configurations ...
}
Web Servers, Apache and Nginx, must be restarted for changes to take effect.