A rival is always somebody (or an entity) you compete with, for being comparable. So for example, Coca-Cola and Pepsi can be considered rivals, because they are both similar in size and compete for business; you would not consider a cheap alternative of these brands a rival of them however, even though they compete for business, for they are not on the same level.
Hence, "rivalry" is rather a personal competition, as pointed out above.
An opponent however is one (or others) who opposes you. There can be a rivalry with an opponent, but this is not necessary to render them an opponent.
So for example, two professional boxers in a ring - each would regard the other an opponent, for they are about to fight one another. They may even have a rivalry, too.
Quite differently, you may find an opponent in your parents, when they express disapproval to one of your ideas or plans - they are not your rivals, but they are an opponent to one of your ideas.
I hope the above makes it clear, but let me know if it does not!