Hadithcore
Sahih al-Bukhari, 1097
sahih

Narrated 'Amir bin Rabi`a:

I saw the Prophet (ﷺ) on his Mount praying Nawafil by nodding his head, whatever direction he faced, but Allah's Messenger (ﷺ) never did the same in offering the compulsory prayers.

حَدَّثَنَا يَحْيَى بْنُ بُكَيْرٍ، قَالَ حَدَّثَنَا اللَّيْثُ، عَنْ عُقَيْلٍ، عَنِ ابْنِ شِهَابٍ، عَنْ عَبْدِ اللَّهِ بْنِ عَامِرِ بْنِ رَبِيعَةَ، أَنَّ عَامِرَ بْنَ رَبِيعَةَ، أَخْبَرَهُ قَالَ رَأَيْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم وَهْوَ عَلَى الرَّاحِلَةِ يُسَبِّحُ، يُومِئُ بِرَأْسِهِ قِبَلَ أَىِّ وَجْهٍ تَوَجَّهَ، وَلَمْ يَكُنْ رَسُولُ اللَّهِ صلى الله عليه وسلم يَصْنَعُ ذَلِكَ فِي الصَّلاَةِ الْمَكْتُوبَةِ‏.‏

References2 variants
In-Book Reference
Book 18, Hadith 17
USC-MSA web (English) reference
Vol. 2, Book 20, Hadith 202 (deprecated numbering scheme)