We've got nginx running on Ubuntu Trusty. It serves several websites over https, running on one ip address.
Randomly, although it seems slightly related to work load, sometimes single requests turn up on the wrong vhost. This leads to requests on lustrum.thalia.nu
being served by thalia.nu
and vice-versa. This then gives nasty error pages as users suddenly end up on a different web site. When you press F5, users then end up on the original target again.
It does not seem browser or operating system related. It's been confirmed to happen on Firefox (Linux, Windows, Mac), Edge (Windows) and Chrome (Linux, Windows, Android) and Safari (iOS).
The issue appears to occur more frequently when the system is put under load, suggesting some sort of race condition.
lustrum.thalia.nu
server {
server_name lustrum.thalia.nu;
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/certs/lustrum.thalia.nu.crt;
ssl_certificate_key /etc/nginx/certs/lustrum.thalia.nu.key;
add_header Strict-Transport-Security "max-age=63072000; preload";
root /var/www/thalia-lustrum/public_html;
location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ [^/]\.php(/|$) {
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/var/run/php5-fpm-thalia-lustrum.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /public_html$fastcgi_script_name;
}
}
thalia.nu
server {
server_name thalia.nu;
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/certs/www.thalia.nu.crt;
ssl_certificate_key /etc/nginx/certs/www.thalia.nu.key;
add_header Strict-Transport-Security "max-age=63072000; preload";
root /var/www/thalia/public_html;
location / {
try_files $uri $uri/ /index.php/$request_uri;
index index.php index.html index.htm;
}
location ~ \.php($|/) {
include /etc/nginx/fastcgi_params;
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_read_timeout 120;
fastcgi_pass unix:/var/run/php5-fpm-thalia-www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /public_html$fastcgi_script_name;
}
}
As you can see, we're running different PHP5-FPM pools for these two domains. These pools are chrooted to different folders and run as different users. PHP-FPM's configuration are otherwise fairly standard as far as I can tell.
We've tried both nginx 1.4.6-ubuntu3 and nginx 1.8.0-1+trusty.
Log telemetry
266.266.266.266 - - [25/Nov/2015:09:24:40 +0100] "GET /committees/175 HTTP/1.1" 302 5 "https://thalia.nu/committees" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0" Host: "thalia.nu" Location: "https://thalia.nu/index.php//committees/wp-admin/setup-config.php"
In this line you can see that the request for the page /committees
suddenly gets redirected to wp-admin
. This appears that the request for /committees
got handled by the thalia-lustrum
PHP-fpm pool...
DNS zone file
We don't see how this can possibly be relevant, but...
;; MX Records
thalia.nu. 300 IN MX 20 relay.transip.nl.
thalia.nu. 300 IN MX 10 ivo.thalia.nu.
;; TXT Records
thalia.nu. 300 IN TXT "v=spf1 a mx a:mulgore.hexon-is.nl a:moonray.hexon-is.nl a:fred.thalia.nu a:ivo.thalia.nu ~all"
;; SPF Records (Sender Policy Framework)
thalia.nu. 300 IN SPF "v=spf1 a mx a:mulgore.hexon-is.nl a:moonray.hexon-is.nl a:fred.thalia.nu a:ivo.thalia.nu ~all"
;; CNAME Records
lustrum.thalia.nu. 300 IN CNAME thalia.nu.
;; A Records (IPv4 addresses)
thalia.nu. 300 IN A 131.174.31.8
www.thalia.nu. 300 IN A 131.174.31.8
ivo.thalia.nu. 300 IN A 131.174.31.8