The rudder must direct the ship, but if a ship hit a headwind, could it travel against it?
You wouldn't actually sail against the wind but at an angle to it, this is known as close hauling. Changing course back and forth, known as tacking, will give you a zig zag pattern in the basic direction you wanted to go.
http://skippercourse.com/how-to-sail-basics-of-sailing
There are also different types of sails too. Some are better against the wind than others.