Using inelastic electron tunneling spectroscopy with the scanning tunneling microscope (STM-IETS) and density functional theory calculations (DFT), we investigated properties of a single H2 molecule trapped in nanocavities with controlled shape and separation between the STM tip and the Au (110) surface. The STM tip not only serves for the purpose of characterization, but also is directly involved in modification of chemical environment of molecule. The bond length of H2 expands in the atop cavity, with a tendency of dissociation when the gap closes, whereas it remains unchanged in the trough cavity. The availability of two substantially different cavities in the same setup allows understanding of H2 adsorption on noble metal surfaces and sets a path for manipulating a single chemical bond by design.