To run cockpit from a "subfolder", as you do with proxy pass there. You will also need to define a "webservice" for the websockets in order for cockpit to communicate via the proxy. First create the file:
sudo nano /etc/cockpit/cockpit.conf
Then put the following content in there, remember to change example.com
to your own domain.
[WebService]
Origins = https://example.com wss://example.com
ProtocolHeader = X-Forwarded-Proto
UrlRoot=/cockpit
Restart the service and that should allow it to load without errors.