Redeem codes are either gifted, purchased or earned. There are various websites that claim to provide COC redeem codes for free but we have never tested those codes. By the way, this only works in the original game and not on private servers because you cannot buy anything in such "Made for fun" servers.
In the original clash of clans, when you make any kind of In-App purchases, it will ask for payment methods where the option for Redeem Codes is located (might not be available for all countries). To earn such gifts, install the app known as "Google Opinion Rewards" and perform the survey tasks they give you. They will provide you with real credits upon completion of tasks that turn into Redeem Codes..