Site have http request error when routed behind Nginx proxy

Magento site content does not load properly when routed behind an Nginx proxy. In the browser console I see a lot of messages for http requests for stylesheets.

For example:

Mixed Content: The page at ‘https://web.MYDOMAIN.com/‘ was loaded over HTTPS, but requested an insecure stylesheet ‘http://web.MYDOMAIN.com/pub/static/frontend/Local/mytheme/en_US/css/local.css‘. This request has been blocked; the content must be served over HTTPS.

Also:

Mixed Content: The page at ‘https://web.MYDOMAIN.com/‘ was loaded over a secure connection, but contains a form that targets an insecure endpoint ‘http://web.MYDOMAIN.com/checkout/cart/add/uenc/aHR0cDovL3dlYi51YndlYnNpdGUuY29tL2Jyb2NrMjAyMC8%2C/product/2417/‘. This endpoint should be made available over a secure connection.

However, if I bypass Nginx and route directly to the backend server, the site loads fine.

I am assuming something in Magento is making it use http instead of https for some requests.

How should I go about fixing this?

submitted by /u/davidbarman
[link] [comments]