WordPress mixed content error

Started by toomanylogins, June 09, 2021, 06:06:23 PM

Previous topic - Next topic
When using the nginx plugin for WordPress site where the certificate is served by nginx and the apache server running behind a proxy is using http WordPress gives a mixed content error.  There are numerous examples of this on the Internet. The answer apparently is to include
proxy_set_header X-Forwarded-Proto https;
However not sure how to incorporate this in the settings.
Any idea
thanks
Paul

It should be already there. However the backend server should process it as well.

Note: nginx will forward what it gets (http or https)

https://github.com/opnsense/plugins/blob/master/www/nginx/src/opnsense/service/templates/OPNsense/Nginx/location.conf#L165

Thanks for reply. This turned out to be a WordPress issue. For anybody with the same problem insert this code at the top of the wpconfig file

/** SSL */ 
define('FORCE_SSL_ADMIN', true); 
// in some setups HTTP_X_FORWARDED_PROTO might contain 
// a comma-separated list e.g. http,https 
// so check for https existence 
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) 
    $_SERVER['HTTPS']='on';

Thank you!
That was so helpful getting my WP site working.

November 27, 2023, 10:28:55 AM #4 Last Edit: December 02, 2023, 04:34:38 PM by Mikuro
Another tip is to check out custom cms vs wordpress. Evaluate the factors mentioned here to determine which option aligns best with your needs and goals.