Pep Guardiola's Bayern meet Benfica at Lisbon's Estadio da Luz with the Germans holding a slender 1-0 lead after Arturo Vidal netted after just 109 seconds of last Tuesday's first leg in Munich.
The Bundesliga leaders maintained the iron-grip on a fourth straight league title with a win at Stuttgart, which left them eight points clear, on Saturday.
But after scraping through 1-0 in their previous three games, Ribery said victory in the south Germany derby was a welcome tonic ahead of their trip to Portugal, even if the performance was again below par.
"The win was good for the head before the game on Wednesday in Lisbon," said the former France winger.
"It wasn't easy for us at the start, we didn't have much room and the first goal was important, but we did better after the break."
Ribery helped give Bayern the lead when his cross was slotted into the Stuttgart goal after a deflection off the ankle of VfB defender Georg Niedermeier.
A second-half David Alaba strike then put Pep Guardiola's Bayern 2-0 up.
Daniel Didavi pulled a goal back for Stuttgart with an hour gone as he recovered from stumbling in the area to chip home while lying on the floor before Brazil winger Douglas Costa blasted in Bayern's late third.
The win gave Bayern three more points in their quest to become the first club to win four successive German league title.
"Now we need three more (league) wins and a draw in order to create something that no team in Germany has ever managed," said Guardiola.
But Bayern's goal-scorer Alaba said the Bavarians will need to put in an improved performance if they are to reach the Champions League semi-finals for a fifth season in a row.
"Stuttgart made life hard for us and we can expect a very intensive game on Wednesday in Lisbon. We'll have to give our all," said Alaba.