Abstract We present an investigation of a coronal cavity observed above the western limb in the coronal red line Fe x 6374 Å using a telescope of Peking University and in the green line Fe xiv 5303 Å using a telescope of Yunnan Observatories, Chinese Academy of Sciences, during the total solar eclipse on 2017 August 21. A series of magnetic field models is constructed based on the magnetograms taken by the Helioseismic and Magnetic Imager on board the Solar Dynamics Observatory (SDO) one week before the eclipse. The model field lines are then compared with coronal structures seen in images taken by the Atmospheric Imaging Assembly on board SDO and in our coronal red line images. The best-fit model consists of a flux rope with a twist angle of 3.1π, which is consistent with the most probable value of the total twist angle of interplanetary flux ropes observed at 1 au. Linear polarization of the Fe xiii 10747 Å line calculated from this model shows a “lagomorphic” signature that is also observed by the Coronal Multichannel Polarimeter of the High Altitude Observatory. We also find a ring-shaped structure in the line-of-sight velocity of Fe xiii 10747 Å, which implies hot plasma flows along a helical magnetic field structure, in the cavity. These results suggest that the magnetic structure of the cavity is a highly twisted flux rope, which may erupt eventually. The temperature structure of the cavity has also been investigated using the intensity ratio of Fe xiii 10747 Å and Fe x 6374 Å.