nginx: Refactor download and extract into functions