Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:41:37

And of His signs are the night and day and the sun and moon. Do not prostrate to the sun or to the moon, but prostate to Allah, who created them, if it should be Him that you worship.  

And among His signs are the night and the day, and the sun and the moon. Do not prostrate to the sun and moon, but prostrate to God Who created them, namely, these fours signs, if it is Him Whom you worship.
القرآن:٤١:٣٧

وَمِنْ آيَاتِهِ اللَّيْلُ وَالنَّهَارُ وَالشَّمْسُ وَالْقَمَرُ ۚ لَا تَسْجُدُوا لِلشَّمْسِ وَلَا لِلْقَمَرِ وَاسْجُدُوا لِلَّهِ الَّذِي خَلَقَهُنَّ إِنْ كُنْتُمْ إِيَّاهُ تَعْبُدُونَ  

{ومن آياته الليل والنهار والشمس والقمر لا تسجدوا للشمس ولا للقمر واسجدوا لله الذي خلقهن} أي الآيات الأربع {إن كنتم إياه تعبدون}.