vmin script error's with multiple ngitx server blocks in conf

hi, firstly virtualmin is great, and this is my first time running nginx instead of apache, and its great that is supported as much as it is.

now this may be my fault but i dont think it is

i think multiple 'server{}' blocks in a site-available's conf is a newish feature ? as having them (i may be missing something out of them) seems to throw errors from various virtulamin scripts such as bw.pl and virtualmin-nginx-lib.pl

here is what the errors look like:

Invalid Nginx config line server{
 at 30
Invalid Nginx config line } at 36
Invalid Nginx config line server{
 at 36
Invalid Nginx config line } at 42
readline() on closed filehandle CFILE at virtualmin-nginx-lib.pl line 68.
Invalid Nginx config line server{
 at 29
Invalid Nginx config line }
 at 35
Invalid Nginx config line server{
 at 30
Invalid Nginx config line } at 36
Invalid Nginx config line server{
 at 36
Invalid Nginx config line } at 42
Invalid Nginx config line server{
 at 36
Invalid Nginx config line } at 42

thes both match up with the number of conf's i have with 2 server blocks, here is one:

server {
    server_name domain.com.au www.domain.com.au;
    listen 118.88.xxx.xxx;
    root /home/domain/public_html;
    index index.html index.htm index.php;
    access_log /var/log/virtualmin/domain.com.au_access_log;
    error_log /var/log/virtualmin/domain.com.au_error_log;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    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 SCRIPT_FILENAME /home/domain/public_html$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT /home/domain/public_html;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass localhost:9002;
    }
 
}
server {
        server_name domain.com www.domain.com;
        listen 118.88.20.103;
        rewrite / http://www.domain.com.au/ permanent;
        rewrite_log off;
}
Status: 
Closed (fixed)

Comments

This is probably a big in Virtualmin's parsing of your nginx config file.

Could you attach the file to this bug report, or email it to me at jcameron@virtualmin.com ?

Thanks ..

So when you created that domain in Virtualmin, did both those server blocks get added to the file right away?

I think the problem is not with the two server blocks, but rather with lines like :

server{

Vitrtualmin gets confused because there is no space between server and { . If you fix that manually in your config files, does the problem go away?

yes actually i think that is it , i noticed it before and tried it but didnt realise it had fixed it which it seems to have.

perhaps you can tests for that when saving the config file: "Test new configuration before saving?" as its not picked up at that point, but errors when some vmin scripts are run on it.

btw i have another problem possibly you can help me with, this is the error:

...
Updating server startists.tv ..
readline() on closed filehandle CFILE at /usr/share/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl line 68.
readline() on closed filehandle CFILE at /usr/share/webmin/virtualmin-nginx/virtualmin-nginx-lib.pl line 68.
...

which i get if for example i run "virtualmin enable-feature --all-domains --virtualmin-nginx"

there is no errors for my other servers.

i will email you my config for that server.

thanks.

I will fix Virtualmin in the next release of the Nginx plugin to properly handle a server{ line.

I think that second error can happen if you have an include directive that points to a non-existent file. Is that perhaps the case in your config?

well looking at the config i emailed you there are 2 logs mentioned and one public_html folder

all are there...

to test things further i tried disabling "nginx website" for that virtual server and recreating it (thus deleting and creating a fresh default config)

same problem.

Ok, thanks - I see the bug that is causing that readline() on closed filehandle warning, and will fix it in the next release.

Other than this, is Virtualmin doing what you expect when you have multiple server blocks?

yes, evrything seems fine thanks. i will close the ticket. thankyou so much for your prompt support.