You are truly lucky. I grew up in Kittery and my first job was delivering newspapers on the shipyard. You have many choices, especially since you won't necessarily have to pay Maine income tax on your or your husband's earnings if you live in Maine. This is due to the Military Spouse Residency Relief Act of 2009.
Military.com - Tax Information from TurboTax: Military Spouse Residency Relief Act and State Taxes
This opens up some good possibilities in Maine (where the shipyard is physically located). Eliot and South Berwick are within commuting distance, and have excellent schools. They also have some newer developments. Berwick and North Berwick are a little further away, and are definitely rural. Schools? Not sure there. Kittery is a nice town but not sure how the schools are looked at these days. When I was in high school, Traip lost its accredidation for a year and didn't have a good reputation. That was 23 years ago though. There are some nice rural-like subdivisions on Haley Road that have popped up over the years, near Fort Foster/Seapoint Beach and convenient to the outlet malls on Rt 1.
For NH, I'd say Greenland, Stratham are nice and close to the shipyard, but a little on the expensive side. Dover, Madbury, Barrington are nice also and within 30 minutes, but beware of the Spaulding Turnpike traffice during rush hours. Portsmouth is nice also, but expensive.
With your tax situation, I'd recommend living in Maine because of slightly cheaper real estate. Just do all your shopping in NH.
If you like four seasons, you will love it on the seacoast. Good luck...