All HTTP status codes 5xx are server errors which means that you cannot "solve" them from JMeter perspective.
Particular HTTP status code 502 means "Bad gateway", as per description:
The HyperText Transfer Protocol (HTTP) 502 Bad Gateway
server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server.
Note: A Gateway might refer to different things in networking and a 502 error is usually not something you can fix, but requires a fix by the web server or the proxies you are trying to get access through.
So in order to "solve" it you need to inspect your application and middleware logs and see what is the root cause of the problem.
If it happens only under the load of 100 users and not reproducible with less amount of threads it indicates that your application is overloaded hence cannot properly respond to certain requests. So you can just report it as a performance bottleneck.
A good idea would be implementing monitoring of the system under test to measure CPU, RAM, Network, Disk usage, etc. as the reason could be as simple as the lack of resources, it can be done using JMeter PerfMon Plugin
If the machine is not overloaded but you're getting this error it means that either system under test is not properly configured for high loads or uses inefficient algorithms somewhere, you can discover what's going on under the hood by looking at profiler tool or APM tool output