Nginx complaining about config error, what is wrong with my /etc/nginx/sites-available/seafile.conf

i am trying to do a new clean setup of seafile with nginx on a debian 10 system using the manual as found on https://download.seafile.com/published/seafile-manual/deploy/README.md

However when i try to start nginx it allready complains at bootup about ningx, when i ask for a status it shows this:
6 packets transmitted, 6 received, 0% packet loss, time 132ms
rtt min/avg/max/mdev = 0.046/0.049/0.054/0.006 ms
root@mycloud:/home/beheer# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2020-04-26 19:02:44 CEST; 22min ago
Docs: man:nginx(8)

Apr 26 19:02:37 mycloud systemd[1]: Starting A high performance web server and a reverse proxy server…
Apr 26 19:02:44 mycloud nginx[499]: nginx: [emerg] unknown directive “<U+FEFF>” in /etc/nginx/sites-enabled/seafile.conf:5
Apr 26 19:02:44 mycloud nginx[499]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 26 19:02:44 mycloud systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Apr 26 19:02:44 mycloud systemd[1]: nginx.service: Failed with result ‘exit-code’.
Apr 26 19:02:44 mycloud systemd[1]: Failed to start A high performance web server and a reverse proxy server.
root@mycloud:/home/beheer# ^C
root@mycloud:/home/beheer#

tryiing to setup cert-bot it shows
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] unknown directive “server” in /etc/nginx/sites-enabled/seafile.conf:3
nginx: configuration file /etc/nginx/nginx.conf test failed

The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError(‘Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] unknown directive “\ufeffserver” in /etc/nginx/sites-enabled/seafile.conf:3\nnginx: configuration file /etc/nginx/nginx.conf test failed\n’)
root@mycloud:/home/beheer# nano /etc/nginx/sites-enabled//seafile.conf

It seems something is wrong wtih my seafile.conf which i took from this page
https://download.seafile.com/published/seafile-manual/deploy/deploy_with_nginx.md

so this how my seafile.conf looks like

log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] “$request” $status $body_bytes_sent “$http_referer” “$http_user_agent” $

server {
listen 80;
server_name mycloud.isgeweldig.net;

proxy_set_header X-Forwarded-For $remote_addr;

location / {
     proxy_pass         http://127.0.0.1:8000;
     proxy_set_header   Host $host;
     proxy_set_header   X-Real-IP $remote_addr;
     proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header   X-Forwarded-Host $server_name;
     proxy_read_timeout  1200s;

     # used for view/edit office file via Office Online Server

     client_max_body_size 0;

     access_log      /var/log/nginx/seahub.access.log seafileformat;
     error_log       /var/log/nginx/seahub.error.log;
}

If you are using FastCGI,

which is not recommended, you should use the following config for location /.

location / {

fastcgi_pass 127.0.0.1:8000;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_script_name;

fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param QUERY_STRING $query_string;

fastcgi_param REQUEST_METHOD $request_method;

fastcgi_param CONTENT_TYPE $content_type;

fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SERVER_ADDR $server_addr;

fastcgi_param SERVER_PORT $server_port;

fastcgi_param SERVER_NAME $server_name;

fastcgi_param REMOTE_ADDR $remote_addr;

fastcgi_read_timeout 36000;

client_max_body_size 0;

access_log /var/log/nginx/seahub.access.log;

error_log /var/log/nginx/seahub.error.log;

}

location /seafhttp {
    rewrite ^/seafhttp(.*)$ $1 break;
    proxy_pass http://127.0.0.1:8082;
    client_max_body_size 0;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_connect_timeout  36000s;
    proxy_read_timeout  36000s;
    proxy_send_timeout  36000s;

    send_timeout  36000s;

    access_log      /var/log/nginx/seafhttp.access.log seafileformat;
    error_log       /var/log/nginx/seafhttp.error.log;
}
location /media {
    root /home/user/haiwen/seafile-server-latest/seahub;
}

}

Does anybody know what is wrong with my seafile.conf

It is hard to imagine a more precise message:
nginx: [emerg] unknown directive “server” in /etc/nginx/sites-enabled/seafile.conf:3

In other words, the problem begins in row 3. So because row 3 is empty, the problem is probably in row 2. And, you will find, when you look:

Compare with this: https://download.seafile.com/published/seafile-manual/deploy/deploy_with_nginx.md

i think you are pointing me to line 1
However nginx complains about line 3, because when i ad 4 emtpy lines
ningx starts to complain about line 7

nginx: [emerg] unknown directive “” in /etc/nginx/sites-enabled/seafile.conf:7 <<<<
nginx: configuration file /etc/nginx/nginx.conf test failed
root@mycloud:/opt/seafile#

Line 7 is:

og_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] “$request” $status $body_bytes_sent “$http_referer” “$http_user_agent” $

server { <<<<<<<
listen 80;
server_name mycloud.isgeweldig.net;

BUT, there seems to be NOTHING wrong with line 7 if compare it to the manual:
https://download.seafile.com/published/seafile-manual/deploy/deploy_with_nginx.md

anybody more thoughts??

There is a byte-order mark (U+FEFF) in your configuration file. Apparently, nginx does not like it and you have to remove it from the file.

What are you saying? Compare the manual and your config! Your row ends with “$”, it mus be a semi-colon.