Many people I´ve spoken to have said there should be more campsites on or near the Autovia de Andalucia, the main drag from Madrid to the Costa del Sol. A lot of traffic flows that way some heading for Malaga or the southern Spanish coast, others heading to Algeciras to take the ferry to Morocco.
Here are a couple of Spanish sites that may fit the bill. The first one is in the flat plains of Castilla-La Mancha, near the town of Almagro - Camping Los Arenales. This is about five hours drive from the Costa del Sol and around 20km from the Madrid - Malaga road.
Castilla La-Mancha is Don Quixote and windmill country a great spot to explore or follow the Don Quixote, Windmill, or Wine Route.
The second is just in the autonomous region of Andalucia, Camping Despeñaperros in Jaen province is literally two minutes off the main road in the gorgeous Sierra Despeñaperros Natural Park. This is an area well worth exploring and an overnight stop here often extends into two or three nights. The drive is around 3 hours from here to Malaga.