The detection of hydrogen sulfide (H2S) and ethanediamine, toxic gases that are emitted from industrial processes, is important for health and safety. An optical sensor, based on the absorption spectrum of tetrakis(4-nitrophenyl)porphyrin (TNPP) immobilized in a Nafion membrane (Nf) and deposited onto an optical waveguide glass slide, has been developed for the detection of these gases. Responses to analytes were compared for sensors modified with TNPP and Nf-TNPP composites. Among them, Nf-TNPP exhibited significant responses to H2S and ethanediamine. The analytical performance characteristics of the Nf-TNPP-modified sensor were investigated and the response mechanism is discussed in detail. The sensor exhibited excellent reproducibilities, reversibilities, and selectivities, with detection limits for H2S and ethanediamine of 1 and 10 ppb, respectively, and it is a promising candidate for use in industrial sensing applications.