When you click on the Open Site button in Local an insecure http webpage is always opened. Is there a generic setting that can be changed somewhere in the config files to always redirect to https? Or do you have to change the Nginx config file for all already created Local websites to achieve this? And what’s the best and recommended code to use in the Nginx config file in that case? I did try to search the community but couldn’t find any appropriate answer how to change the Nginx config file.
@ben.turner There must be a way to edit the Nginx config file to always redirect to https. I have tried several solutions but without success. Do you have any suggestion how to edit the Nginx config file? Or is it a bug that an insecure http webpage is opened when you click on the Open Site button? I’m running the latest Local 6.2.0 version on macOS Monterey 12.1 with PHP 7.4.1 and MYSQL 5.7.28. No other modifications to config files or add-ons.
@ben.turner Automatic login via the Admin button also doesn’t work in Local 6.2.0 with Nginx as web server.
You’re right that there likely exists nginx rules for forcing HTTPS. Local doesn’t ship with those because a self-signed cert needs to be generated for the site before you can access it over HTTPS.
Local allows you to generate that cert by clicking the “Trust” button on the site overview page.
Afterwards, the next thing to consider is that WordPress stores the actual site domain in the database. Because of that, forcing a HTTPS redirect within nginx often times will cause a redirect loop. To avoid that, I usually recommend doing a search and replace on the database so that the new HTTPS protocol is used.
The easiest way to run that search-and-replace is using wp-cli, which you can do by right-clicking on the site in Local and selecting “Open Site Shell.” Within the terminal that is opened, run a command like this (updating with your domain)
wp search-replace 'http://example.local' 'https://example.local'
This process is pretty easy if you are wanting to experiment with different nginx configuration settings. Just navigate to the
sitename/conf/nginx/site.conf.hbs file and make the changes you want. Since this is a handlebars template, you’ll need to stop the site and restart it so that Local can compile it down to the actual configuration file for your system!
Is this for the One-click admin feature? This should be working, but if you are having issues, I’d love to know a bit more about what’s going on. Can you record a screencast of what you are experiencing so that I can get a better idea of what’s going on?
Many thanks for your reply. I’m well aware of all those things. In some cases, however, it is desirable to force https. I have tried several Nginx rules but without success since they don’t work with the Local config. So I was hoping for some rules that worked and already was tested.
Regarding the other issue it’s the one-click admin feature and automatic login that doesn’t work with Nginx. But it does work with Apache though. And I think it has worked with previous versions. It’s easy to replicate, but don’t forget to clear cache, cookies and local storage in between.
Keep up the good work!
I noticed one more thing. When you click on the Open Site button an insecure http homepage is opened. But when you click on the Admin button a secure https admin page is opened? And FORCE_SSL_ADMIN is not defined in the wp-config.php file. So there must be some function already in place in Local to force https when a certificate is set-up.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.