server {
  server_name www.example1.com;
  location / {
    proxy_pass http://backend;
  }
  location ~* (\.jpg|\.png|\.css)$ {
    valid_referers none blocked example1.com www.example1.com;
    if ($invalid_referer) {
        return 444;
    }
  }
}