H2 antagonist drugs (such as cimetidine) work by blocking the H2 subtype of histamine receptors. These are different receptors from those involved in the allergic response.
Since the advent of proton pump inhibitors, use of these drugs to treat ulcers has declined.