Refactor and update nginx config