"morbid fear of being shut up in a confined space," coined 1879 (in article by Italian-born, French-naturalized Swiss-English physician Dr. Benjamin Ball), with -phobia "fear" + Latin claustrum "a bolt, a means of closing; a place shut in, confined place, frontier fortress" (in Medieval Latin "cloister"), from past participle of claudere "to close" (see close (v.)).
word-forming element meaning "friendship, fondness, tendency toward," and in recent use "abnormal attraction to," from Greek philia "affection," from philos "loving," which is of uncertain origin. Related: -philic.
<a href="https://www.etymonline.com/word/claustrophilia">Etymology of claustrophilia by etymonline</a>
Harper, D. (n.d.). Etymology of claustrophilia. Online Etymology Dictionary. Retrieved $(datetime), from https://www.etymonline.com/word/claustrophilia