Page 1 of 1

Nginx fails to start after a simple restart

Posted: Wed Aug 01, 2018 1:30 pm
by Sanana94
Hello everyone,

Today I was trying to change some php.ini configs in my server but I couldn't save it getting the error "Error: failed to start with new config".
Which is strange, because before the Nginx security update (from 0.9.8-20 to 0.9.8-21) I could easily edit any configuration without problems.

Before trying anything else, I decided to restart my VPS. Once it rebooted Nginx stopped working completely and I could not start it again.

I've done a clean uninstall/reinstall of Nginx but the issue is still there:

Code: Select all

2018/08/01 15:08:47 [emerg] 32129#32129: open() "/home/admin/conf/web/17kgroup.it.auth" failed (2: No such file or directory) in /home/admin/conf/web/17kgroup.it.nginx.conf:60
line 60 is:

Code: Select all

/home/admin/conf/web/17kgroup.it.auth;
Any advice in how to proceed is very appreciated.

I still can't get why it used to work fine before and why I could not even edit php.ini file via VestaCP not touching anything.

Thank you all for your time!

Re: Nginx fails to start after a simple restart

Posted: Wed Aug 01, 2018 3:38 pm
by Sanana94
UPDATE, Help needed.

Okay, I noticed that the nginx.conf file was different than the one here https://github.com/serghey-rodin/vesta/ ... nginx.conf

I've manually changed the file to be the same as the reference on github.
here's what it looks like now:

Code: Select all

user                    admin;
worker_processes        1;
error_log               /usr/local/vesta/log/nginx-error.log;
pid                     /var/run/vesta-nginx.pid;

events {
        worker_connections  128;
        use                 epoll;
}

http {
    # Main settings
    sendfile                        on;
    tcp_nopush                      on;
    tcp_nodelay                     on;
    client_header_timeout           1m;
    client_body_timeout             3m;
    client_header_buffer_size       2k;
    client_body_buffer_size         256k;
    client_max_body_size            256m;
    large_client_header_buffers     4   8k;
    send_timeout                    30;
    keepalive_timeout               60 60;
    reset_timedout_connection       on;
    server_tokens                   off;
    server_name_in_redirect         off;
    server_names_hash_max_size      512;
    server_names_hash_bucket_size   512;


    # Log format
    log_format  main    '$remote_addr - $remote_user [$time_local] $request '
                        '"$status" $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
    log_format  bytes   '$body_bytes_sent';
    access_log          /usr/local/vesta/log/nginx-access.log main;


    # SSL PCI Compliance
    ssl_protocols               TLSv1.2 TLSv1.1 TLSv1;
    ssl_ciphers                 EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_session_cache           shared:SSL:10m;
    ssl_prefer_server_ciphers   on;


    # Mime settings
    include             /usr/local/vesta/nginx/conf/mime.types;
    default_type        application/octet-stream;


    # Compression
    gzip                on;
    gzip_comp_level     9;
    gzip_min_length     512;
    gzip_buffers        8 64k;
    gzip_types          text/plain text/css text/javascript
                        application/x-javascript application/javascript;
    gzip_proxied        any;


    # Proxy settings
    proxy_redirect      off;
    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_pass_header   Set-Cookie;
    proxy_connect_timeout   90;
    proxy_send_timeout  90;
    proxy_read_timeout  90;
    proxy_buffers       32 4k;
    fastcgi_read_timeout 300;

    # Error pages
    error_page          403          /error/403.html;
    error_page          404          /error/404.html;
    error_page          502 503 504  /error/50x.html;


    # Vhost
    server {
        listen 8083;
        server_name     _;
        root            /usr/local/vesta/web;
        charset         utf-8;

        # Fix error "The plain HTTP request was sent to HTTPS port"
        error_page      497 https://$host:$server_port$request_uri;

        ssl                  on;
        ssl_certificate      /usr/local/vesta/ssl/certificate.crt;
        ssl_certificate_key  /usr/local/vesta/ssl/certificate.key;
        ssl_session_cache    shared:SSL:10m;
        ssl_session_timeout  10m;

        error_page      404     /error/404/index.html;
        error_page      403     /error/index.html;
        error_page      500     /error/index.html;

        location / {
            expires max;
            index   index.php;
        }

        location /error/ {
            expires max;
            index   index.html;
        }

        location /rrd/ {
            expires off;
            internal;
        }

        location /backup/ {
            root    /;
            internal;
        }

        location ~ \.php$ {
            include         /usr/local/vesta/nginx/conf/fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME /usr/local/vesta/web/$fastcgi_script_name;
            fastcgi_param   QUERY_STRING    $query_string;
            fastcgi_pass    unix:/var/run/vesta-php.sock;
            fastcgi_intercept_errors        on;
            break;
        }
    }
}
Unfortunately, I get this error now:

Code: Select all

2018/08/01 17:30:41 [emerg] 5165#5165: bind() to 0.0.0.0:8083 failed (98: Address already in use)
2018/08/01 17:30:41 [emerg] 5165#5165: still could not bind()
__________________

UPDATE 2:

So, here's the situation:
I've reinstalled nginx again, the file in vestacp looks like this, which I don't think it is the correct one:

Code: Select all

user  nginx;
worker_processes  1;

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"';
log_format bytes '$body_bytes_sent';
    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}
After this, I've been getting errors about .auth files missing, so I opened every single .conf file where nginx got this error (around 2 files for 4 websites):

Code: Select all

2018/08/01 15:08:47 [emerg] 32129#32129: open() "/home/admin/conf/web/domain.com.auth" failed (2: No such file or directory) in /home/admin/conf/web/domain.com.nginx.conf:60
And edited the line from

Code: Select all

include /home/ddd/conf/web/xxxxx.ltd.auth
to

Code: Select all

include /home/ddd/conf/web/xxxxx.ltd.auth*
after this everything went back to normal, except for the webmail service that won't allow me to log-in giving back the error "log-in failed" every single attempt.

Workaround:
I Deleted every single website, restored a backup, changed every single e-mail password manually and then I could use the website and mails with no problem.

NOTE: I CAN'T RESTART NGINX NOW. If I do that, in order to make it work again I have to do all the process again:
1) Delete every single website
2) Recreate every single website via VestaCP
3) Restore Backup
4) Change every single mail password
5) Enjoy and tell everyone to change their passwords again.

It's a pain, I'm not sure if this is a bug or an error in my configuration.

Re: Nginx fails to start after a simple restart

Posted: Fri Aug 03, 2018 10:22 am
by flanders
Hi,

I too have the same problem. Nginx fails to start after a restart. it is a clean install.
Centos 7 and nginx-php-fpm vesta. I tried many times on a development server but got always the same error !

Re: Nginx fails to start after a simple restart

Posted: Sun Aug 05, 2018 5:21 pm
by mehargags
You worked way too hard than needed... which also shows you did not take time to read through the forums and jumped onto invasive, complicated actions like removing Nginx and reinstalling it which would actually break VestaCP integration with it.

When your Nginx doesn't start... you don't have to delete it/reinstall it. Just do nginx -t and it will give you syntax error in any of the configs.
The config's sometimes get corrupted, you can try to "REBUILD WEB" for that VestaCP user where error is shown or manually correct the syntax.
I Deleted every single website, restored a backup, changed every single e-mail password manually and then I could use the website and mails with no problem.
Exactly what I said above... re-configuring website makes the config's afresh but you can re-make configs without deleting domains/sites/mail but just doing a rebuild of web/mail/DNS etc.

Re: Nginx fails to start after a simple restart

Posted: Mon Aug 06, 2018 11:03 am
by flanders
I notified this issues after I added a new template in nginx (for cms Prestashop) and rebuild the user web.

I tried to delete those files create from mine and it works well again....

I tried to copy the template moodle and rename it "prestashop" (tpl and stpl files) too and Nginx fails to start with a restart !

Re: Nginx fails to start after a simple restart

Posted: Wed Aug 08, 2018 9:58 am
by Sanana94
@Mehargags
First, thank you for your time looking into this. I tried to google and spent a lot of time before trying what I did. I knew that what I was doing was not good at all so I ended up forcing stuff to work because I needed it to be online ASAP.


Because it is still hard to find quick solutions with vesta, I guess the more we talk about it the better it is. I hope I am not creating too much of a trouble for you all.

So what now? Is there any way to restore the integration of Nginx?

Again, I don't take it for granted so... thank you!

Re: Nginx fails to start after a simple restart

Posted: Sun Aug 26, 2018 8:24 pm
by Sanana94
up

Re: Nginx fails to start after a simple restart

Posted: Sun Aug 26, 2018 9:06 pm
by DigitalIT
When your Nginx doesn't start... you don't have to delete it/reinstall it. Just do nginx -t and it will give you syntax error in any of the configs.
The config's sometimes get corrupted, you can try to "REBUILD WEB" for that VestaCP user where error is shown or manually correct the syntax.
The above is for future reference and also do a nginx -t and paste the newest error you are receiving. If at a company for hosting that can do a snapshot or image of your system - I would recommend that before attempting the "REBUILD WEB" Function. Backups are a major necessity we forget at times. The command to use is "v-rebuild-web-domains $USER" without the quotes. If it does not work please go change the the directory/folder "/usr/local/vesta/bin" and do that command there.

Let us know if you make some progress.