How can I animate a centipede?

I’m currently working on a Centipede-like boss for an RPG featuring many segments on its body with two legs per each of these segments. However, I’m trying to figure out how to set up the centipede to move like a real insect would: having its head walk where it wants to and its body follow along behind it. In other words, if I want the centipede to turn around as it’s following the player, I need its head to start moving around its body and head in the direction that way, rather than allowing the character to set its body rotation to 180 degrees all at once, as this does not look good.

I’ve attached a rough illustration of what I’m talking about if needed. Please let me know if you can think of how to make this skeleton setup work, or if you have a different setup to suggest altogether, and how I can get the segments behind the insect’s head to follow it.