Military man

My husband of 2 years and I just moved back to his hometown after a year away and he is preparing to be deployed this September. We lost a baby in Feburary and it helped us grow and brought us closer. Since we've been back home he has been anything but normal. Ignoring me. Yelling at me. Acting like sex is a chore. His buddy who is deploying with him as well has been at our house EVERY SINGLE DAY since we've been here (9 days) and everyday hubby and I agree no friends today so we can have time together. And the next thing I know, his friend is back and I am left alone for hours if not the entire day. I feel totally hopeless. I never knew  things could change so quickly. I have no idea how to even talk to him anymore because he is so defensive. I've tried looking at it like its just me and I have something to change. But I promise I'm a very mature person and I can see it really is not me. 
If anyone else has been through this or has ideas of how to approach hard hass husbands. Please comment. I worry that my marriage is on the line with little time to be together is left. :/