Valley progressed to the next round of the FA Vase but made hard work of it against lower league Shawbury United.
After going a goal down early on Rugby responded to overturn the deficit to lead by two before half time but then after seemingly cruising during the second half Shawbury made life extremely difficult in the closing stages once they got a goal back and came close to forcing the game to a penalty shoot-out.
Town boss Grant Joshua made three changes from the previous game - a 2-0 home win over Coton Green - with Stephan Morley and new signing Lewi Burnside occupying the two full-back berths and Louis Samuels recalled to the starting line-up.
The visitors had fired an early warning when Harry Woodburn's nicely-struck, rising effort from the edge of the box flew just over the bar, and then they took the lead with just five minutes on the clock when Ablay Sowe was the first to react to a looping header over the top of the Rugby defence to nip in ahead of the oncoming Ash Bodycote and flick the ball home.
A Rivel Mardenborough shot on-the-turn after good work from Aaron Nuttall lacked the power to trouble Shawbury keeper Jack Boswell, and Burnside's shot was blocked away for a corner, before Town levelled things up when Ryley Nicholson rose the highest to head in Morley's corner from the left-hand-side on 13 minutes.
Samuels then had a shot blocked after Devonn O'Sullivan had set him up, before the hosts edged ahead when Charlie Tilley ran onto Burnside's delivery to apply a neat low finish past Boswell - with the visitors' appeal for the ball going out of play before Burnside's pass turned down.
Mardenborough failed to connect to a Tilley cross and Samuels had a shot blocked, as the hosts pushed for a third ahead of the interval - which then did arrive when Jake Wormleightton was on-hand at the back-post to help home Nuttall's dinked cross following a quickly-taken Rugby free-kick.
Shawbury did have a couple of chances to reduce the arrears before the half-time whistle though, with Joe Care finding the side-netting from a corner, before the same player headed a David Howells' set-piece delivery wide from a decent position.
Valley started the new period brightly, with Burnside forcing a neat low save from Boswell after Mardenborough had pulled the ball back to him, although at the other end Ethan Pickford's free-kick was deflected up onto the roof of the net and a further quick free-kick from Pickford almost caught Rugby napping, but Bodycote was off his line smartly to smother the ball before Sowe was able to control it.
Boswell then gathered a Nuttall cross with Samuels poised to strike, and O'Sullivan headed Morley's deep cross against the post as Town enjoyed a decent spell of pressure.
This continued with Mardenborough releasing Nuttall, but he took the ball too wide and his shot was comfortably taken by Boswell, before United rendered the tie live again after Wormleighton was dispossessed in a dangerous position which ultimately gave Sowe a run on goal and he duly obliged with his second of the game via a low finish into the bottom corner.
Both sides created a number of good chances in the final twenty minutes, with Tilley's shot from a tight angle saved, and Sowe missing out on a hat-trick attempt when his touch let him down in the box.
Nuttall's half-volley from the edge of the box was tipped over by Boswell, and Pickford put one just wide for Shawbury.
Care and Joey Nixon also both missed out for the visitors, before Town were given the perfect opportunity to put the game safe when Howells pushed Mardenborough in the back after Tilley had played in the Rugby striker, but Mardenborough's penalty was kept-out by a full-length Boswell save.
Boswell's counterpart Bodycote then stepped into the limelight in the closing minutes with two impressive stops in close succession to secure Valley their place in the First Round Proper draw.
He first beat away Pickford's snap-shot to his near post and then did well to deny Shawbury skipper Ollie Cooper's rising effort.