This oversimplified model shows that it is possible to sail in a zigzag against the wind. The force produced by the wind (red) is always perpendicular to the sail in this simple model. The reaction force of water acting on the boat (blue) is always perpendicular to the boat axis. The magnitude of this reaction force is just enough to make the net force (black) act along the boat's axis. You can change the magnitude and direction of any of these vectors using the controls.
A real sail is far more complex. This Demonstration is a good simplified model to understand the role of reaction forces, which are forces that will grow just enough to make the system obey the constraints. The shape of a real boat makes it very difficult to move sideways in the water. The constraint in this oversimplified model is that sideways motion is totally impossible; therefore, the reaction force of the water is always just enough to have the total force (the vector sum of the wind and water forces) in the direction of the boat axis.