The novel takes place mostly in the town of Casterbridge, a fictional town in the fictional county of Wessex in England. Many of Hardy's novels take place in "Wessex," and certain place names appear in more than one novel. These novels are referred to as his "Wessex novels," for obvious reasons. Wessex is based loosely on the real-life county of Dorset, where Hardy grew up. Take a look at the maps of Hardy's Wessex in the "Best of the Web" section to get a sense of where Casterbridge is supposed to be relative to London and other places in Great Britain.
Now that you have a sense of where Casterbridge is supposed to be, what is it like? Well, the narrator describes Casterbridge as follows:
Casterbridge was in most respects but the pole, focus, or nerve-knot of the surrounding country life; differing from the many manufacturing towns which are as foreign bodies set down, like boulders on a plain, in a green world with which they have nothing in common. Casterbridge lived by agriculture at one remove further from the fountain-head than the adjoining villagers – no more. (9.26)
In other words, Casterbridge is not very far removed from the natural cycles and rhythms that are so important to agriculture. The people who live here understand nature and are more connected to the land than, say, the residents of a town like Manchester, famous for its industry and mills. The townspeople of Casterbridge might live in a town, but they understand the country.