Custom config NGINX

Hello!

I have Bunkerweb self-hosted on Debian 13.

I need some help with custom NGINX configurations.
I would like to add these NGINX parameters to a service via a custom configuration:

# lock down the admin page / delete this part if you need to access it
location /admin {
return 404;
}

location / {
proxy_pass $forward_scheme://$server:$port;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;

# Disable custom error page
error_page 404 = /404_default;
location = /404_default {
    internal;
    # => default NGINX 404 page
}

}

I am getting errors saying that it must not be linked to a service, or that proxy pass is not allowed here.

Can you help me about the best pratices for add this config Nginx on my services please ?

Thanks a lot.

You cant do that , but you need to use bunkerweb ui under where in admin ui under Reverse proxy include : there you specify the path to your custom config.
In general Bunkerweb generate each time new config, it make no sense to change the core Nginx config, because it get regenerated after each restart of Bunkerweb , so only one option left is to add your config via docker composer yaml, and then Bunkerweb would not be able to delete this extension. This is how stuff done in Bunkerweb, you extend and not edit standard nginx conf.