Bad Gateway When Using Proxy

Hello, My site is using lighttpd as the webserver. The problem occured in this situation.

  1. When I open plain php file without database query it’s normal. Even using proxy and with https protocol
  2. When I open php file with database query it’s 502 Bad Gateway when I open it using https protocol, but it’s normal when not using proxy and I open using http protocol.

image