nginx generation function optimization