Dictionary definitions of rhapsody would include: “an exaggerated feeling of pleasure or enthusiasm; an exaltation, or some other deep emotion” and “a piece of poetry or prose of particularly acute feeling, and generally irregular rhythm, suitable for reading aloud, such as parts of Homer”. The word itself comes from the Greek for a recital of epic poetry.

In music, a rhapsody can be all or any of this in musical form.

After a fairly low-key start – the term was first applied to six pieces for piano by the relatively unknown Bohemian composer and teacher Vaclav Tomasek in about 1803 – it lay dormant for over 40 years until Liszt let fly with the first few of his 19 “Hungarian Rhapsodies” for piano (later orchestrated.) This nationalistic theme was taken up and the rhapsody became a sort of enthusiastic fantasia on folk or folk-like melodies.

Examples of this are:

Brahms would have none of this - his Rhapsodies for the piano, notably the Opus 79 pair, have not a hint of folk or statement of place, but are rhapsodic in their ebullience, and are music affectionately written for music’s sake, as was Brahms’ wont. At the other end of both the musical and emotional spectrum is Brahms’ “Alto Rhapsody” for contralto, male chorus, and orchestra. To a text by Goethe, it concerns a man’s plea for release from the pain of regret of a life lived wrongfully and is as deeply emotional as anything Brahms ever wrote.

Of the two most well known classical rhapsodies, one is a set of variations on an old and ubiquitous musical phrase and, like many rhapsodies, could just as aptly be called a fantasia or capriccio; and the other can be described as “crossover music”.

A piece of music that fits the requirements of both the dictionary and musical terms, and, whilst not classical, is still a classic, is "Queen's" "Bohemian Rhapsody"

References:

“Oxford Companion to Music”

“The Grove Concise Dictionary of Music”