Using [shields][1] is the only surefire method through which to prevent your village from being attacked for an extended period of time.

I would reccomend spending all of your resources on upgrades before you leave, so that attackers have nothing to steal. However, changing your base to a farming layout will divert an attackers atention from your loot to your town hall.

One good example of a farming layout is TH9 (where the town hall is outside the walls):

![enter image description here][2]

<sup>Image from [this thread][3] on the Clash of Clans forum</sup>


  [1]: http://clashofclans.wikia.com/wiki/Shields
  [2]: https://i.sstatic.net/maFUh.jpg
  [3]: http://forum.supercell.net/showthread.php/228374-COMPILATION-Best-TH9-farming-bases