# certbot can't found server block in external config files in nginx



## adi (Aug 25, 2022)

Freebsd 13.1, nginx/1.22.0, certbot 1.29.0

If I use


> certbot  install --cert-name doman.com


and server block is in /usr/local/etc/nginx/nginx.conf
cerbot install cert correctly

When I move server block to separate files  servers/domain.com.conf
and use in main config


> http {
> [..]
> include "servers/*.conf";
> }



certbot show


> Could not automatically find a matching server block for domain.com. Set the `server_name` directive to use the Nginx installer.



My servers/domain.com.conf is



> server {
> access_log /var/log/nginx/domain.com.access.log;
> error_log /var/log/nginx/domain.com.error.log;
> listen 80;
> ...


Of course the website itself (without SSL) works with this configuration.



> /usr/local/etc/nginx/servers # ls -al
> total 12
> drwxr-xr-x  2 root  wheel  512 Aug 25 22:19 .
> drwxr-xr-x  3 root  wheel  512 Aug 25 22:34 ..
> -rw-r--r--  1 root  wheel  259 Aug 23 01:00 domain.com.conf



Do you have any idea how to get certbot to run when using separate configuration files in nginx?

certbot -vvvvvvvv install --cert-name domain.com is in attachment but nothing interesting info there.

Best Regards


----------



## zomar (Aug 26, 2022)

I had many issues with certbot (mostly with its dependencies, lots of dependencies)
and migrated to 
https://www.freshports.org/security/acme.sh/ - ZERO dependencies


----------



## SirDice (Aug 26, 2022)

It's probably easier if you just supply the webroot directory directly. 

`certbot install --cert-name domain.com --webroot /home/user/www/domain.com`

I don't rely on the Apache or Nginx plugin and just let certbot write to the website's root directly.


----------



## sko (Aug 26, 2022)

zomar said:


> I had many issues with certbot (mostly with its dependencies, lots of dependencies)
> and migrated to
> https://www.freshports.org/security/acme.sh/ - ZERO dependencies


THIS

acme.sh is a plain, simple shell wrapper that 'just works'™, is very easy to use/configure yet still very flexible.


----------

