It may be possible to construct an underground facility/base and then, you could use the surface of the moon (or Mars) for the "shield".
Or tunnel into one of the "mountains" . Same concept. Who knows, maybe some of the "SDI" (aka Star Wars defense) concepts could be tried out here, sort of like the asteroid deflector on the Star Trek TOS episode, "The Paradise Syndrome".