Nginx config gets overwritten on every site restart

What issue or error are you experiencing?

I’m trying to customize the nginx config for a new site, but every time I restart the site, the config gets overwritten removing all my customizations.

I’m trying to add this:

# Block direct access to private portal uploads.
location ^~ /wp-content/uploads/private/ {
	return 404;
}

In order to protect som private uploads handled by a custom plugin.


What steps can be taken to replicate the issue? Feel free to include - screenshots, videos, etc

  1. Run the latest LocalWP (9.2.9) on Mac Silicon.
  2. Add the change above to the nginx config file of a site.
  3. Restart the site in order for the change to take effect.

The nginx config file is overwritten and all customizations are removed.


System Details

  • Local Version: 9.2.9 (ARM64)

  • Operating System (OS) and OS version: MBP M1 - Sonoma 14.2.1 (23C71)


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)

local-lightning-verbose.log (783.6 KB)


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Hey @david_sah!

I just tested this on a Local site, but the added NGINX rule stayed in place after restarting.

Are you adding this rule to nginx.conf.hbs or to site.conf.hbs? If you’re adding it to nginx.conf.hbs, that would explain why it’s getting overwritten since it’s the global configuration file, but if you add it to site.conf.hbs, that is your site-specific file.

Hi @Nick-B!

Thanks for taking a look so quickly. I think I understand now.

I added it to the site.conf (not .hbs) file directly in the Application support folder. That’s the file i found when I did a search for .conf files. Wasn’t aware of the .hbs template files that is used to genereate the actual conf file.

That explains it.

Will try again updating the correct .hbs template file. That should solve the issue.

Thanks again!

1 Like

Sounds great @david_sah! Thank you for following up :green_heart:

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.