The Nginx configuration fragment included into sites (`includes/nginx_advanced_include.conf`) uses the `$host` variable in ways which are incompatible with site aliases. `$host` contains the `Host` header value, which is not necessarily the same as the name of the site directory.

location = /favicon.ico {
  access_log    off;
  log_not_found off;
  expires       30d;
  try_files     /sites/$host/files/favicon.ico $uri =204;
}

A site called "example.com" with an alias "example.org" will store its files in sites/example.com/files/. The existing configuration will serve requests for http://example.com/favicon.ico but not http://example.org/favicon.ico. I'm a newcomer to Nginx, but I believe that using `$server_name` instead of `$host` in these cases should resolve the problem.

Comments

omega8cc’s picture

Title: Nginx config for favicon, etc. wrong with aliases » Use $server_name instead of $host in all sites/ paths to avoid broken URLs to static files for domain aliases in D7 (Nginx)
Version: 6.x-1.8 » 6.x-1.x-dev
Assigned: Unassigned » omega8cc
Priority: Minor » Normal

Right, we should use $server_name instead.

Thanks for the report!

omega8cc’s picture

Assigned: omega8cc » Unassigned
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 2fc157d on dev-drupal-8, dev-nginx-6.x-1.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x by omega8cc:
    Issue #1544144 by thsutton - Use $server_name instead of $host in all...
  • Commit 139f867 on dev-drupal-8, dev-nginx-6.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-subdir-multiserver, 6.x-2.x-backports, dev-helmo-3.x by omega8cc:
    Issue #1544144 by thsutton - Use $server_name instead of $host in all...