Lock axis/rotation on 2d plane with capsule collider

I have a GameObject with a RigidBody, a capsule collider and a plane attached to it. The capsule rolls down a hill with the plane facing Z. This works fine until the collider hits obstacles and starts to rotate in every direction. This is supposed to simulate 2d and I would like to lock the collision/rotation/position in the Z-axis. I have read about Configurable Joint but I cant seem to get it to work right. What parameter should I be looking for? Is it better to do this with code in the controller script?

For your 2D plane you could use the function LookAt.

And there is already an answer how to lock the rotation in one axis: Locking LookAt.

Fixed it with the Configurable Joint locking ZMotion, Angular XMotion, Angular YMotion. Hope this can help others with the same problem.