While it is said that a prison existed there since the 17th century, this actual building was erected in 1876. It has hosted many political prisoners, both during tsarist and communist eras. You can read about its atmosphere during the stalinist terro in Solzhenitzin and Shalamov.