A process in which a protein is transported to, or maintained at, a location in a peroxisome via the endoplasmic reticulum.