If you have a ceiling fan junction box that is too close to the wall, you can install an electrical box extender. These devices are available in a variety of sizes, and they allow you to extend the electrical box enough that it sits flush with the wall surface.
Getting Started
Before you start installing your ceiling fan, make sure the electrical circuit that it is on can handle the weight of the fan and its lights. You can do this by checking the breakers in your breaker panel.
You also want to confirm that the existing ceiling box is rated for a fan, and that it is properly mounted to the ceiling joists. If not, you may need to reinforce or replace the ceiling box.
The best way to support a ceiling fan is with an electrical box that is rated for the fan’s weight and has a brace between the ceiling joists to help hold it in place. These types of boxes are also rated for vibration resistance.
Orbit Industries manufactures a line of ceiling fan and light fixture support boxes. These octagonal and pancake boxes are used to support ceiling fans, lighting fixtures, and other electrical devices.
The octagonal version can support up to 50 lbs. It is made with a highly engineered thermoplastic material for durability, and it has a plaster-ring bracket design that allows the box to be installed between different thicknesses of wallboard. It is UL classified for 2-hour or less fire resistant assemblies.