Wikipedia
Cancelli are lattice-work, placed before a window, a door-way, the tribunal of a judge, or any other place.
Hence the occupation of Cancellarius, which originally signified a porter who stood at the latticed or grated door of the emperor's palace. Carinus gave great dissatisfaction by promoting one of these cancellarii to city prefect. Other cancellarii were legal scribes or secretaries who sat within the lattice-work which protected the tribunals of the judges from the crowd. The chief scribe in Constantinople eventually acquired the term and from his position came the modern " chancellor".
The canghellor of Medieval Wales was also a development of this position. He administered the peasantry of the king's demesne and was charged with holding the king's pleas and "waste".