Ranger, 29, made his Newcastle debut in the Championship in 2009 against West Bromwich Albion, coming off the bench.
He featured 51 times for Newcastle, and has also appeared for Swindon Town, Blackpool and Southend United.
He also represented England at Under-19s level.
Manager Gabriel Zakuani said: “I’ve known Nile for many years and we grew up in the same area. He has all the talent in the world and knows he has a point to prove.
"In the conversations we have had, he wants an opportunity to get himself back on the map.
“I believe he can easily play for any team in League One and most Championship clubs. He has promised me he will get his head down and prove to everyone that the penny has dropped.
"This opportunity will allow people to see he still has the hunger to succeed."
Keep up-to-date with our exclusive email newsletters.
Subscribe