Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Nginx error, my sites are all gone

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Locked
  • Print view
Advanced search
12 posts
  • 1
  • 2
  • Next
Ckubs
Posts: 12
Joined: Fri Dec 09, 2016 11:53 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Nginx error, my sites are all gone

Post by Ckubs » Tue Jan 31, 2017 1:13 pm

Everything was normal till today when none of them were resolved by the server. Nginx was stopped and didn't wanted to start.

The error I get is

nginx: [emerg] "alias" directive is not allowed here in /home/admin/conf/web/nginx.conf:103
nginx: configuration file /etc/nginx/nginx.conf test failed

Thank you for your help.
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: Nginx error, my sites are all gone

Post by mehargags » Tue Jan 31, 2017 2:57 pm

look carefully, there is a syntax error in you /home/admin/conf/web/nginx.conf at line 103.

Sometimes (sparingly) the scripts fail to parse all paramteres correctly and write some orphan text that causes syntax error.

If you can figure out, post your /home/admin/conf/web/nginx.conf here
Top

Ckubs
Posts: 12
Joined: Fri Dec 09, 2016 11:53 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: Nginx error, my sites are all gone

Post by Ckubs » Tue Jan 31, 2017 3:16 pm

Apparently line 103 before "# Error pages" is blank.

Code: Select all

# Server globals
user                    www-data;
worker_processes        auto;
worker_rlimit_nofile    65535;
error_log               /var/log/nginx/error.log crit;
pid                     /var/run/nginx.pid;


# Worker config
events {
        worker_connections  1024;
        use                 epoll;
        multi_accept        on;
}


http {
    # Main settings
    sendfile                        on;
    tcp_nopush                      on;
    tcp_nodelay                     on;
    client_header_timeout           1m;
    client_body_timeout             1m;
    client_header_buffer_size       2k;
    client_body_buffer_size         256k;
    client_max_body_size            64m;
    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;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-Xss-Protection "1; mode=block" always;


    # 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          /var/log/nginx/access.log main;
    access_log off;


    # Mime settings
    include             /etc/nginx/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 text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype;
    gzip_proxied        any;
    gzip_disable        "MSIE [1-6]\.";

    # 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;


    # Cloudflare https://www.cloudflare.com/ips
    set_real_ip_from   199.27.128.0/21;
    set_real_ip_from   173.245.48.0/20;
    set_real_ip_from   103.21.244.0/22;
    set_real_ip_from   103.22.200.0/22;
    set_real_ip_from   103.31.4.0/22;
    set_real_ip_from   141.101.64.0/18;
    set_real_ip_from   108.162.192.0/18;
    set_real_ip_from   190.93.240.0/20;
    set_real_ip_from   188.114.96.0/20;  
    set_real_ip_from   197.234.240.0/22;
    set_real_ip_from   198.41.128.0/17;
    set_real_ip_from   162.158.0.0/15;
    set_real_ip_from   104.16.0.0/12;
    set_real_ip_from   172.64.0.0/13;
    #set_real_ip_from   2400:cb00::/32;
    #set_real_ip_from   2606:4700::/32;
    #set_real_ip_from   2803:f800::/32;
    #set_real_ip_from   2405:b500::/32;
    #set_real_ip_from   2405:8100::/32;
    real_ip_header     CF-Connecting-IP;


    # SSL PCI Compliance
    ssl_session_cache   shared:SSL:10m;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers        " *cipher-string* :!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";


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


    # Cache settings
    proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
    proxy_cache_key "$host$request_uri $cookie_user";
    proxy_temp_path  /var/cache/nginx/temp;
    proxy_ignore_headers Expires Cache-Control;
    proxy_cache_use_stale error timeout invalid_header http_502;
    proxy_cache_valid any 1d;


    # Cache bypass
    map $http_cookie $no_cache {
        default 0;
        ~SESS 1;
        ~wordpress_logged_in 1;
    }


    # File cache settings
    open_file_cache          max=10000 inactive=30s;
    open_file_cache_valid    60s;
    open_file_cache_min_uses 2;
    open_file_cache_errors   off;


    # Wildcard include
    include             /etc/nginx/conf.d/*.conf;
}
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: Nginx error, my sites are all gone

Post by mehargags » Tue Jan 31, 2017 8:51 pm

You are pasting the global config not the one it is showing error in.
What OS are you on ? Please always state OS and Version

Paste the content of this specific file

Code: Select all

nano /home/admin/conf/web/nginx.conf 
Top

Ckubs
Posts: 12
Joined: Fri Dec 09, 2016 11:53 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: Nginx error, my sites are all gone

Post by Ckubs » Wed Feb 01, 2017 3:03 pm

I'm using Ubuntu 16.04. And here's the code

Code: Select all

server {
    listen      ##IP##:80;
    server_name site.info www.site.info;
    root        /home/admin/web/site.info/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/site.info.log combined;
    access_log  /var/log/nginx/domains/site.info.bytes bytes;
    error_log   /var/log/nginx/domains/site.info.error.log error;

    location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9002;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/admin/web/site.info/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/admin/web/site.info/stats/;
        include /home/admin/web/site.info/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.site.info.conf*;
}
        alias   /home/admin/web/site.ro/stats/;
        include /home/admin/web/site.ro/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.site.ro.conf*;
}
server {
    listen      ##IP##:80;
    server_name site.ro www.site.ro;
    root        /home/admin/web/site.ro/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/site.ro.log combined;
    access_log  /var/log/nginx/domains/site.ro.bytes bytes;
    error_log   /var/log/nginx/domains/site.ro.error.log error;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Very rarely should these ever be accessed outside of your lan
    location ~* \.(txt|log)$ {
        allow 192.168.0.0/16;
        deny all;
    }

    location ~ \..*/.*\.php$ {
        return 403;
        }

    # No no for private
    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/)\. {
        return 403;
    }

    location / {
        try_files $uri @rewrite;

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$)|^/update.php {
            fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9001;
            fastcgi_index   index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_intercept_errors on;
            include         /etc/nginx/fastcgi_params;
        }
    }

    location @rewrite {
        # You have 2 options here
        # For D7 and above:
        # Clean URLs are handled in drupal_environment_initialize().
        rewrite ^ /index.php;
    }

    location ~ ^/sites/.*/files/styles/ {
        try_files $uri @rewrite;
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/admin/web/site.ro/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/admin/web/site.ro/stats/;
        include /home/admin/web/site.ro/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.site.ro.conf*;
}
server {
    listen      ##IP##:80;
    server_name subdom.site.ro www.subdom.site.ro;
    root        /home/admin/web/subdom.site.ro/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/subdom.site.ro.log combined;
    access_log  /var/log/nginx/domains/subdom.site.ro.bytes bytes;
    error_log   /var/log/nginx/domains/subdom.site.ro.error.log error;

    location / {

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9003;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;

    location /error/ {
        alias   /home/admin/web/subdom.site.ro/document_errors/;
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }

    location /vstats/ {
        alias   /home/admin/web/subdom.site.ro/stats/;
        include /home/admin/web/subdom.site.ro/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.subdom.site.ro.conf*;
}
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: Nginx error, my sites are all gone

Post by mehargags » Thu Feb 02, 2017 6:22 am

I can't figure out the problem out of my sight,

can you do config test for nginx and paste the results:

Code: Select all

nginx -c /etc/nginx/nginx.conf -t
and then

Code: Select all

nginx -c /home/admin/conf/web/nginx.conf -t

Code: Select all

nginx -c /home/admin/conf/web/snginx.conf -t
Top

Ckubs
Posts: 12
Joined: Fri Dec 09, 2016 11:53 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: Nginx error, my sites are all gone

Post by Ckubs » Thu Feb 02, 2017 12:08 pm

First error I got was nginx: [emerg] "alias" directive is not allowed here in /home/admin/conf/web/nginx.conf:52

Deleted what looked like a leftover alias. And now I get

"server" directive is not allowed here in /home/admin/conf/web/nginx.conf:1
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Nginx error, my sites are all gone

Post by tjebbeke » Thu Feb 02, 2017 1:30 pm

Try to rebuild the user. v-rebuild-user admin or in the control panel.
Top

Ckubs
Posts: 12
Joined: Fri Dec 09, 2016 11:53 pm

Os: Ubuntu 17x
Web: nginx + php-fpm
Re: Nginx error, my sites are all gone

Post by Ckubs » Thu Feb 02, 2017 8:27 pm

tjebbeke wrote:Try to rebuild the user. v-rebuild-user admin or in the control panel.
Thank you so much. It worked.
Top

plutocrat
Posts: 232
Joined: Fri Jan 27, 2017 9:16 am

Os: Ubuntu 17x
Web: apache + nginx
Re: Nginx error, my sites are all gone

Post by plutocrat » Fri Feb 03, 2017 12:24 am

Looks like there was a duplicated section.

Code: Select all

    location /vstats/ {
        alias   /home/admin/web/site.info/stats/;
        include /home/admin/web/site.info/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.site.info.conf*;
}
        alias   /home/admin/web/site.ro/stats/;
        include /home/admin/web/site.ro/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.site.ro.conf*;
}
Should be

Code: Select all

    location /vstats/ {
        alias   /home/admin/web/site.info/stats/;
        include /home/admin/web/site.info/stats/auth.conf*;
    }

    include     /etc/nginx/conf.d/phpmyadmin.inc*;
    include     /etc/nginx/conf.d/phppgadmin.inc*;
    include     /etc/nginx/conf.d/webmail.inc*;

    include     /home/admin/conf/web/nginx.site.info.conf*;
}
Top


Locked
  • Print view

12 posts
  • 1
  • 2
  • Next

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password