Finally, after a week of headbanging, I managed to figure out certbot’s installation process with nginx and how to deploy python apps with uwsgi.
1. Make sure that existing nginx is not listening on port 443
There was a tiny trick with certbot’s nginx plugin - if you have a virtualhost, say, in
/etc/nginx/sites-available/test.com, you must not listen on port 443. In other words, make sure that:
|  |  | 
Otherwise, you might get a ‘connection reset by peer’ error. This is because there is already a listen on 443 on the default server block.