This paper considers the optimal rejection with Zero Steady-State Error for nonlinear systems with step and ramp composite disturbances. Firstly, the nonlinear system model with composite disturbances is transformed into linear system with disturbances, then we construct an augmented linear system without disturbances. With respect to the quadratic performance indexes of infinite horizon, consequently, the problem of disturbance rejection with zero steady-state error is transformed into the problem of designing an optimal controller for the augmented plant without disturbances, which can eliminate static error. Thus the disturbances can unfold of the signal through the Taylor series for the form of polynomial function of time, and obtain optimal controller design approach to eliminate the general disturbance. Finally, a practical example is given to illustrate the effectiveness of the theory.