كتاب صلاة المسافرين وقصرها
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 701

'Abdullah b. 'Amir b. Rabi'a has reported on the authority of his father that he had seen the Messenger of Allah (ﷺ) observing Nafl player at night on a journey on the back of his ride in whichever direction it turned its face.

وَحَدَّثَنَا عَمْرُو بْنُ سَوَّادٍ، وَحَرْمَلَةُ، قَالاَ أَخْبَرَنَا ابْنُ وَهْبٍ، أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، عَنْ عَبْدِ اللَّهِ بْنِ عَامِرِ بْنِ رَبِيعَةَ، أَخْبَرَهُ أَنَّ أَبَاهُ أَخْبَرَهُ أَنَّهُ، رَأَى رَسُولَ اللَّهِ صلى الله عليه وسلم يُصَلِّي السُّبْحَةَ بِاللَّيْلِ فِي السَّفَرِ عَلَى ظَهْرِ رَاحِلَتِهِ حَيْثُ تَوَجَّهَتْ ‏.‏
Reference : Sahih Muslim 701
In-book reference : Book 6, Hadith 50
USC-MSA web (English) reference : Book 4, Hadith 1506
  (deprecated numbering scheme)