I have a rest microservice and would like to setup nginx as a reverse proxy for it. I am little confused about which approach to follow:
Can someone explain which one is better
For what do you need the proxy? When it's for exposing the service to the outside world, have a look at Ingress / Ingress Controller: https://kubernetes.io/docs/concepts/services-networking/ingress/
In my opinion, running nginx in a separate pod is a better option because that way you can scale up and down application separately from a proxy. Usually, we use one container with proxy and few with API.
Option 1 will work but it is looks to be inefficient way to do what you have mentioned. Nginx is a highly capable server (footprint/runtime resources) and can easily be able to serve multiple applications from a separate pod. So I think the option 2 is a better option.
Running nginx separately will have following advantages:
I have had a similar requirement. I used a single nginx on a separate pod to serve multiple (250) application deployments running on different pods. I used proxy_pass directive to get the job done.