The crackdown by Turkish President Tayyip Erdogan, who has for years tried to stamp out what he sees as illegal online activity, has strained relations with NATO allies and raised alarms among civil liberties advocates.