I'm running into a problem with my project setup and could really use some help. My frontend is built with React, and it connects to a .NET backend using WebSockets. I'm using Docker Compose to containerize everything, and I'm working with a self-signed SSL certificate. I've generated .pem files, converted them to .pfx, and added the certificate path and password in my Docker Compose configuration.
Here's what I've got working: HTTP redirects to HTTPS, the app runs fine locally without Docker, normal API calls over HTTPS work smoothly, and my certificate is applied correctly with no SSL warnings in the browser.
However, I'm facing a specific issue: the WebSocket connection fails when I'm running inside Docker, even though everything else works perfectly. This WebSocket code connects just fine outside the Docker environment. I want to keep using self-signed certificates and have React connect via wss://, preferably getting the WebSocket to work inside Docker just like it does when running locally.
In summary, my React and .NET app functions as expected with self-signed SSL on local, but the WebSockets break when I switch to Docker, despite the fact that HTTPS works without any warning. I'm looking for insights on whether the issue stems from my certificate setup, Kestrel configuration, or the need for a reverse proxy.
1 Answer
It sounds like your issue could be related to the WebSocket connection setup within the Docker environment. Can you provide more details about how it fails? Is it a timeout or some kind of TCP or HTTP error? Knowing this could really help pinpoint the problem.

I think the backend API isn't even being called. You might want to check the logs carefully.