nginx corrupt config because of vitualmin

here is what I did:

  1. install nginx module

  2. edit module config to set sites-enabled/sites-active paths

  3. go to "nginx webserver -> other settings"

  4. try to set "number of worker processes" to 4.

when I apply that config, nginx refuse to start... when I look in the config I see virtualmin has destroyed config ;)

destroyed:

user nginx;
worker_processes 4;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
        default_type application/octet-stream;
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

what it should be:

user  nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
        server_names_hash_bucket_size 128;
}

please fix... not good that it eats config for breakfast! :P

Status: 
Closed (fixed)

Comments

try it on fresh system with this install proces:

# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-nginx
# sed -i 's/gpgcheck=0/gpgcheck=1/' /etc/yum.repos.d/nginx.repo
# yum install nginx
# mkdir -p /etc/nginx/sites-available; mkdir -p /etc/nginx/sites-enabled; if ! grep -q "sites-enabled" /etc/nginx/nginx.conf; then sed -i 's/\(include \/etc\/nginx\/conf\.d\/\*\.conf;\)/\1\n\tinclude \/etc\/nginx\/sites-enabled\/*;/' /etc/nginx/nginx.conf; fi
# yum install wbm-virtualmin-nginx wbm-virtualmin-nginx-ssl

then go to module config and set it to use sites-enabled/available paths, and save.

then go and try to set the worker connections. boom, cookie monster eats config! :P

Could you attach the original and corrupt configs to this bug report, or email them to me as attachments at jcameron@virtualmin.com ? Otherwise their format gets messed up by the bug tracker..

the 2 configs above are actually correct, they did not get changed at all by the bug tracker...

i have only the correct config on my server now so i cant attach both, and the correct config is useless to show anyway because it works now and can be edited fine by virtualmin... (after i fixed it in vim)

either way i dont have the most interestig thing of them all... the default config before it was eaten by virtualmin.

its possible the bug only happens with official nginx default config file. if you have a blank vm you can do the steps in post 2 and its exactly what i did.

looking at the above it seems virtualmin eats 2 lines after "worker_processes 4;" and eats 2 lines after "default_type application/octet-stream;"

look carefully, its very interesting that exactly 2 lines are missing below each "eaten" / edited part... and think about it... both "worker_processes" and "default_type" are changed from "other settings" in nginx module which is where i pressed save and config broke, so it proves that virtualmin edited both... and you can see extra indent of "default_type" line after virtualmin edit(changes 4 spaces to 1 tab after editing a value)...

so yes this is totally virtualmins fault ;) it is hungry for config file breakfast. :D

Ok, I see the issue .. Virtualmin isn't handling multi-line directives with continuations.

I'll need to make some changes to handle this.

hmm, okay good, hope you find the bug! :)

Ok, I found the bug .. this will be fixed in the next release of the Nginx plugin to virtualmin.

Automatically closed -- issue fixed for 2 weeks with no activity.