Offshore drilling rigs are the foundation of oil and gas exploitation in water areas. Their spatial and temporal distribution, state attributes and other information directly reflect the exploitation level of regional oil and gas resources. Therefore, it is very important to build an automatic detecting method for offshore drilling rigs with good performance to accurately capture the temporal and spatial distribution and state of oil and gas exploitation activities. At present, there are two main groups of methods for offshore drilling rigs: invariant feature-based methods and nighttime firelight-based methods. Methods based on invariant location are more subjective in terms of their parameter settings and require intensive computation. Nighttime light-based methods are largely unable to identify offshore drilling rigs without associated waste gas ignition. Furthermore, multiple offshore drilling rigs in close proximity to one another cannot be effectively distinguished with low spatial resolution imagery. To address these shortcomings, we propose a new method for the automatic identification of offshore drilling rigs based on Landsat-7 ETM+ images from 2018 to 2019, taking the Caspian Sea as the research area. We build a nominal annual cloud and cloud shadow-free Normalized Difference Water Index (NDWI) composite by designing an optimal NDWI compositing method based of the influence of cloud and cloud shadow on the NDWI values of water, bare land (island) and offshore drilling rigs. The classification of these objects is simultaneously done during the compositing process, with the following rules: water body (Max_NDWI > 0.55), bare land (island) (Min_NDWI < −0.05) and offshore drilling rig (0 < Mean_NDWI < 0.4). A threshold segmentation and postprocessing were carried out to further refine the results. Using this method, 497 offshore platforms were automatically identified using a nominal annual cloud and cloud shadow-free NDWI composite image and Google Earth Engine. Validation using Sentinel-2 Multispectral Imager (MSI) and Google Earth images demonstrated that the correct rate of offshore drilling rig detection in the Caspian Sea is 90.2%, the missing judgment rate is 5.3% and the wrong judgment rate is 4.5%, proving the performance of the proposed method. This method can be used to identify offshore drilling rigs within a large water surface area relatively quickly, which is of great significance for exploring the exploitation status of offshore oil and gas resources. It can also be extended to finer spatial resolution optical remote sensing images; thus small-size drilling rigs can be effectively detected.