As an adjective, "devious, shady, illegal," by 1640s. The notion is of business done out of public view. The association with sodomy is from at least 19c.; compare also back-door man "a married woman's lover," African-American vernacular, early 20c.
also door-nail, "large-headed nail used for studding batten doors for strength or ornament," late 14c.; see door (n.) + nail (n.). The figurative expression dead as a doornail is attested as early as the word itself.
But ich haue bote of mi bale bi a schort time, I am ded as dore-nail. ("William of Palerne," c. 1375).
Compare key-cold "lifeless, inanimate, devoid of heat, cold as a metal key" (1510s). Also in Middle English as a symbol of muteness (domb as a dor nail, c. 1400).
also in-door, 1670s, opposed to outdoor, contracted from within door; the form indoors is attested from 1759 (within-doors is from 1750); as an adverb from 1801.
c. 1300 (mid-13c. in surnames), "side door, small entranceway, private door," from Old French posterne "side or rear gate," earlier posterle, from Late Latin posterula (Medieval Latin posterna) "small back door or gate," diminutive of Latin posterus "that is behind, coming after, subsequent," from post "after" (see post-).
curtain hung at the doorway or entrance to a room," 1843, from French portière, which is formed in French from porte "door," or from Medieval Latin portaria, fem. singular of Latin portarius "belonging to a door or gate," from porta "city gate, gate; door, entrance," from PIE root *per- (2) "to lead, pass over."
A curtain hung at a doorway, or entrance to a room, either with the door or to replace it, to intercept the view or currents of air, etc., when the door is opened, or for mere decoration. [Century Dictionary]