Rub a cloth over the inside of the washer after each load. If you're too lazy for this, and let's face it, who isn't? Try to do this once a week. Keep a roll of paper towels nearby, and wipe down the glass on the inside of the door. Then, peel back the rubber door seal, and clean in there. You'll notice little grooves. Water sits here, collects and... yep, you guessed it! Stinks. Just cover your finger with a paper or real towel, stick in the grooves, and spin the washer slowly. You'll notice there are two grooves. Clean both. Check out the gunk.
Clean the drain pump filter. This should be done about every two weeks. The drain pump filter gets slowed down, and fills up with stinky water over time. Old water that never drained sits here, as does lint and other odd items. The drain pump filter is usually located at the front bottom of the washer. If you're lucky enough to a drain plug next to it, pull that out, put the hose in a bucket and let it empty before opening the filter. If you don't have a plug, have your bucket ready under the filter before you open it--you'll be shocked how much water flows out! Once that is done, pull the filter out, and clean it.
Clean the tub. Some washers have a "tub clean" feature. If yours does, pour two cups of bleach into the detergent area. Then run the tub clean with an empty washer. If your front loader doesn't have this feature, pour the bleach and run it, empty, on its hottest cycle.