I manged to fixed it. First I purged nginx and reinstalled it, then I created a new conf file with the following:
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_pass http://127.0.0.1:81;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
}
server {
listen 80;
server_name studio.example.com;
location / {
proxy_pass http://127.0.0.1:81;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
}
After that I ran certbot and now everything is working fine.