We study the magnetic proximity effect on a two-dimensional topological insulator in a CrI3/SnI3/CrI3 trilayer structure. From first-principles calculations, the BiI3-type SnI3 monolayer without spin-orbit coupling has Dirac cones at the corners of the hexagonal Brillouin zone. With spin-orbit coupling turned on, it becomes a topological insulator, as revealed by a non-vanishing Z2 invariant and an effective model from symmetry considerations. Without spin-orbit coupling, the Dirac points are protected if the CrI3 layers are stacked ferromagnetically, and are gapped if the CrI3 layers are stacked antiferromagnetically, which can be explained by the irreducible representations of the magnetic space groups and , corresponding to ferromagnetic and antiferromagnetic stacking, respectively. By analyzing the effective model including the perturbations, we find that the competition between the magnetic proximity effect and spin-orbit coupling leads to a topological phase transition between a trivial insulator and a topological insulator.