Enforce SSL on WP Interface with NGinx

Hey folks! It could be nice to have an option to Enforce SSL on the sites when using Site Domains and running under NGinx. With Apache it’s easy but with NGinx, every tip we find on the internet doesn’t work on LocalWP version of .conf as I’ve seen others say here at the forums.

Would there be a way to enforce directly on the NGinx .conf file? I’ve been searching here on this forums but couldnt find any tip on how to enforce SSL when the WordPress site is runing under NGinx.

Thank you very much in advance, cheers!

Hi @fabiofava!

The short answer is we don’t have a simple Force HTTPS/SSL option at this time but it’s definitely a feature request we’ve seen users express interest in:

with NGinx , every tip we find on the internet doesn’t work on LocalWP version of .conf as I’ve seen others say here at the forum

Could you expand on anything you’ve tried or seen attempted so far that hasn’t worked? I’ve never attempted this myself, so I don’t want to provide something you’ve already tried.

Hey @Nick-B thank you for your reply

I’ve tried all possible wp-config.php and functions.php solutions I could find at the web, but none has worked for my sites running under LocalWP.

On the other hand, wp-config.php solutions on define works for WP-Admin and WP-Login. My current solution is to open the WP-Admin and from there select to open the site: this way it opens https with a self-assigned local SSL from the browser.

I’ve also tried some nginx conf options, but they also didn’t work on LocalWP.

I’ll keep looking forward that maybe some day this comes out. Thanks!

I’ve tried some things to enable GZip and Browser Cache Expiry (copied from the very good performance premium plugin from my hosting company. But nothing they suggest for NGinx has worked. And they host on NGinx, so they know how it works.

I can’t remember exactly, but if my mind doesn’t fail, I’ve also tried a couple suggestions (from stackoverflow or something like that) to enforce SSL on NGinx servers, but it also didn’t work as far as I can remember. Any suggestion?

I’m sure nowadays almost every WordPress website is SSL/HTTPS2.

With WP sites, one important part of getting HTTPS working across the board is to update the domain in the database so that it’s using https. You can do this using a terminal by clicking “Site Overview > Site Shell” and within the terminal that opens running this command:

wp search-replace 'http://mysite.local' 'https://mysite.local'

Note that you need single quotes and that the first domain is the search (with regular http) and the second string is the replacement (with secure https)

If the domains in the DB aren’t changed, then WP will always output whatever domain is set in it’s DB.

1 Like

Hey @ben.turner thanks for getting back!

I’ve done it on the 2 sites I currently have on Local. On the first 2 changes were done and nothing happened, so it continues to load http instead. On the second, loads of changes have been done and then I’ve had a lot of errors at frontend:

I’ve rolled-back to my last backup (nothing else was change since then), so no troubles here. It really loaded https but with all those visual (non-fatal) errors. WP-Debug is DISABLED and screen of them also DISABLED on wp-config.

Any light that could help me? Maybe I should change only specific tables on WP? I’m not a great coder or PHP adminer, but I can do things and restore as they don’t work. Thank you if you can help me debugging that.

Cheers!