I’ve observed if I say nothing (because I simply don’t know how to react), opinionated people think you agree with them, which I don’t. I don’t care.
what I want to tell him, next time he starts ranting: ‘I don’t care what you think, leave me alone’.
However, I may have to work with this person in the future, so what about ‘you don’t have to tell me everything you think, most of the time I don’t pay attention’ and if he keeps pushing it ‘it’s tiring working with a person who has to rant to feel good, it’s boring and makes me ignore you, which is a problem, because we work together.’ And leave.
What about ‘everybody has problems, maybe talk to a therapist? I cannot help you’.
Or maybe simply leaving when he starts his rants?
“I’m not interested in discussing this matter with you; please drop the subject so I can focus on work.”
Politely insist he drop it multiple times. If he refuses, depending on how severely this is affecting you, you are well within your rights to seek out a supervisor to discuss the issue. But I’d be as plain and direct as possible to minimize any chance of him turning the tables on you and complaining to a superior first.
Or, make it clear you’re not interested and just go on ignoring him?