كتاب صلاة المسافرين وقصرها
6  
The Book of Prayer - Travellers
(4)
Chapter: It is permissible to offer voluntary prayers atop one’s mount when travelling, no matter what direction it is facing
(4)
باب جَوَازِ صَلاَةِ النَّافِلَةِ عَلَى الدَّابَّةِ فِي السَّفَرِ حَيْثُ تَوَجَّهَتْ ‏‏
Sahih Muslim 700 c

Ibn 'Umar reported that the Messenger of Allah (ﷺ) used to say prayer on his camel while coming from Mecca to Medina, in whatever direction his face had turned; and its was (in this context) that this verse was revealed:

" So whether you turn thither is Allah's face" (ii. 115).
وَحَدَّثَنِي عُبَيْدُ اللَّهِ بْنُ عُمَرَ الْقَوَارِيرِيُّ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، عَنْ عَبْدِ الْمَلِكِ بْنِ أَبِي سُلَيْمَانَ، قَالَ حَدَّثَنَا سَعِيدُ بْنُ جُبَيْرٍ، عَنِ ابْنِ عُمَرَ، قَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم يُصَلِّي وَهُوَ مُقْبِلٌ مِنْ مَكَّةَ إِلَى الْمَدِينَةِ عَلَى رَاحِلَتِهِ حَيْثُ كَانَ وَجْهُهُ - قَالَ - وَفِيهِ نَزَلَتْ ‏{‏ فَأَيْنَمَا تُوَلُّوا فَثَمَّ وَجْهُ اللَّهِ‏}‏
Reference : Sahih Muslim 700c
In-book reference : Book 6, Hadith 43
USC-MSA web (English) reference : Book 4, Hadith 1499
  (deprecated numbering scheme)