The proximity fuse
The proximity fuse detects the distance to the missile its target. It detects the first metal part which is closest to the missile. For a BUK missile at around 17 meters from the target the fuse will let the explosives in the warhead explode. Because the explosives are in the core of the warhead and surrounded by fragments, the fragments will spread out.
The proximity fuse in a missile like BUK is "side looking" rather, than "front looking" (probably at an angle of about 60deg from missile axis to both sides). It is designed to detonate when it passes close to target, there is no point to detonate ahead of a typical aircraft target. The speed of shrapnels from the warhead is much higher than closure speed of the missile/target, so the warhead doesn't work like a "shotgun shot". It just explodes passing close to target and the shrapnels are thrown to the sides fast enough to hit it (shrapnel is several times faster than the missile).
Type of proximity fuses are 9E241, 9E241M1 and most recent 9E346.
So if the missile was going head-on horizontally or from above with slight side offset, then the warhead detonated as soon as the cockpit came into field of view (FOV) of side-looking proximity fuse antennas. And looking at the cockpit damage, it was only few meters, so most of the shrapnel was absorbed by front part of the fuselage with very high fragment density. The spread pattern of warhead shrapnels is not omnidirectional, almost all of the fragments are directed to the sides. Nearly all other plane parts were outside of the shrapnel kill-zone, only one wing and it's engine could get some.
The image below shows the proximiy fuse angles of detonation (for type 5E50).
5E50 is a proximity fuse which is almost equal to 5E241M1 with some improvements near ground surface.
Depending from relative speed of the missile and target, the proximity fuse will give a command to detonate warhead.
The figure below shows how the detection angle depends from speeds. Basically, the faster the speed of the target, the more narrow the angle of detection, the more difficult to detect the target and thus the more unlikely missile will detonate.
On high speed angle near 30 degree, on slowest close to 60.
What is the x-axis. What is relative speed missile-target?
On the x-axis the sum of the speed of the missile plus the speed of the target is shown. The radar in the missile is able to calculate this speed based on the speed of the radar return from target.
The line numbered 2 is the scenario with MH17 (no electronic counter measures). A BUK missile is designed to attack enemy fighter aircraft which will execute electronic counter measures to distract the rader of the missile.
This article ^in Russian language has a lot of info on proximity fuse.