I have also found this tutorials, but i am not able to get it work.
Are i am allowed to modifiy the config file /etc/nginx/sites-enabled/default?
Will this file not be overwritten by the lets encrypt certbot and/or a system update?
And, to be honest, i also don’t know how this is working with multiple server blocks in the nginx configs.
Normally place your configurations in /etc/nginx/sites-available. Insiode this folder is already a default file. Inside this file is a line include /etc/nginx/sites-dietpi/*.conf; which means, you can just place your configs inside /etc/nginx/sites-dietpi. This folder will never gets overriden by nginx because it’s not from the default config.
After that you reload ngninx: sudo systemctl reload nginx
With this method you can have multiple config files in sites-dietpi but only link the ones you want to have enable.
But with this config i get an error in the logs if i restart nginx:
Jan 23 21:57:37 DietPi nginx[72533]: 2024/01/23 21:57:37 [emerg] 72533#72533: duplicate listen options for [::]:443 in /etc/nginx/sites-enabled/homeasisstant:5
Jan 23 21:57:37 DietPi systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jan 23 21:57:37 DietPi systemd[1]: Reload failed for nginx.service - A high performance web server and a reverse proxy server.
Jan 23 21:58:53 DietPi systemd[1]: Reloading nginx.service - A high performance web server and a reverse proxy server...
Jan 23 21:58:53 DietPi nginx[72600]: 2024/01/23 21:58:53 [emerg] 72600#72600: duplicate listen options for [::]:443 in /etc/nginx/sites-enabled/homeasisstant:4
Jan 23 21:58:53 DietPi systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jan 23 21:58:53 DietPi systemd[1]: Reload failed for nginx.service - A high performance web server and a reverse proxy server.
@Joulinar Ok, i removed the ones you suggested. But after a nginx -t i get following errors:
2024/01/26 17:10:52 [warn] 264414#264414: conflicting server name "home.domain.example" on [::]:443, ignored
2024/01/26 17:10:52 [warn] 264414#264414: conflicting server name "home.domain.example" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Looks like you configured your host name within 2 different files. I guess once in /etc/nginx/sites-enabled/default and another one within the new file. Best to remove the block from /etc/nginx/sites-enabled/default