If you do your own custom solution it will be more complicated and you have to play around a little bit. If you do a simple search for “nginx” here in the forum, you will find multiple discussions about it.
One that is interesting for your problem is this one: