(38) باب مَنْ أَفْطَرَ فِي السَّفَرِ لِيَرَاهُ النَّاسُ
Narrated Tawus:
Ibn `Abbas said, "Allah's Messenger (ﷺ) set out from Medina to Mecca and he fasted till he reached 'Usfan, where he asked for water and raised his hand to let the people see him, and then broke the fast, and did not fast after that till he reached Mecca, and that happened in Ramadan." Ibn `Abbas used to say, "Allah's Messenger (ﷺ) (sometimes) fasted and (sometimes) did not fast during the journeys so whoever wished to fast could fast, and whoever wished not to fast, could do so."
Reference: Sahih al-Bukhari 1948
In-book reference: Book 30, Hadith 55
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 3, Book 31, Hadith 169