Skip to content

nginx can't start again

Moved Solved Configure
20 4 3.1k 1
  • hello guys again, something odd happened today, i’ve noticed that my website was down, it show

    err connection refused
    

    i’ve tried to restart nginx but i get some error that i’m not understand…

    root@:~# sudo service nginx restart
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    root@:~# sudo service nginx start
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    
    Jan 22 14:22:43 justoverclock.it systemd[1]: Starting A high performance web server and a reverse proxy server>
    Jan 22 14:22:43 justoverclock.it nginx[2386]: nginx: [emerg] "ssl_certificate" directive is not allowed here i>
    Jan 22 14:22:43 justoverclock.it nginx[2386]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Jan 22 14:22:43 justoverclock.it systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAIL>
    Jan 22 14:22:43 justoverclock.it systemd[1]: nginx.service: Failed with result 'exit-code'.
    Jan 22 14:22:43 justoverclock.it systemd[1]: Failed to start A high performance web server and a reverse proxy
    
  • @justoverclock done, i’ve removed that line and works again

    @phenomlab fixed it, removed the two lines and all works again

  • It seems to be you have a problem with your configuration file of nginx located at
    /etc/nginx/nginx.conf

    especially with the following directive :
    @justoverclock said in nginx can't start again:

    Jan 22 14:22:43 justoverclock.it nginx[2386]: nginx: [emerg] “ssl_certificate” directive is not allowed here i>

    command result ?

    sudo nginx -t
    
  • It seems to be you have a problem with your configuration file of nginx located at
    /etc/nginx/nginx.conf

    especially with the following directive :
    @justoverclock said in nginx can't start again:

    Jan 22 14:22:43 justoverclock.it nginx[2386]: nginx: [emerg] “ssl_certificate” directive is not allowed here i>

    command result ?

    sudo nginx -t
    

    @downpw

    nginx: [emerg] "ssl_certificate" directive is not allowed here in /etc/nginx/sites-enabled/justoverclock.it.conf:42
    nginx: configuration file /etc/nginx/nginx.conf test failed
    
  • @justoverclock said in nginx can't start again:

    /etc/nginx/sites-enabled/justoverclock.it.conf

    command result ? :

    cat /etc/nginx/sites-enabled/justoverclock.it.conf
    
  • @justoverclock said in nginx can't start again:

    /etc/nginx/sites-enabled/justoverclock.it.conf

    command result ? :

    cat /etc/nginx/sites-enabled/justoverclock.it.conf
    

    @downpw said in nginx can't start again:

    @justoverclock said in nginx can’t start again:

    server
    {
            server_name justoverclock.it www.justoverclock.it autoconfig.justoverclock.it autodiscover.justoverclock.it;
      root /home/justoverclock/public_html;
      index index.php index.htm index.html;
      access_log /var/log/virtualmin/justoverclock.it_access_log;
      error_log /var/log/virtualmin/justoverclock.it_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/justoverclock/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/justoverclock/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;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_param HTTPS $https;
      location ~ ^/ads.txt {
      root /var/www;
    }
      location /
      {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
            rewrite ^\Q/mail/config-v1.1.xml\E(.*) $scheme://$host/cgi-bin/autoconfig.cgi$1 break;
            rewrite ^\Q/.well-known/autoconfig/mail/config-v1.1.xml\E(.*) $scheme://$host/cgi-bin/autoconfig.cgi$1 break;
            rewrite ^\Q/AutoDiscover/AutoDiscover.xml\E(.*) $scheme://$host/cgi-bin/autoconfig.cgi$1 break;
            rewrite ^\Q/Autodiscover/Autodiscover.xml\E(.*) $scheme://$host/cgi-bin/autoconfig.cgi$1 break;
            rewrite ^\Q/autodiscover/autodiscover.xml\E(.*) $scheme://$host/cgi-bin/autoconfig.cgi$1 break;
            ssl_certificate /home/justoverclock/ssl.combined;
            ssl_certificate_key /home/justoverclock/ssl.key;
      }
      client_max_body_size 5G;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      location /cgi-bin/
      {
        gzip off;
        root /home/justoverclock/cgi-bin;
        fastcgi_pass unix:/var/fcgiwrap/163388321568860.sock/socket;
        fastcgi_param SCRIPT_FILENAME /home/justoverclock$fastcgi_script_name;
      }
      listen 165.232.65.12:443 ssl default_server;
        ssl_certificate /etc/letsencrypt/live/justoverclock.it-0001/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/justoverclock.it-0001/privkey.pem; # managed by Certbot
    
      if ($scheme = http)
      {
        rewrite ^/(?!.well-known)(.*) https://justoverclock.it/$1 break;
      }
      fastcgi_read_timeout 60;
    
    }
    server
    {
        if ($host = justoverclock.it) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
    
            server_name justoverclock.it www.justoverclock.it autoconfig.justoverclock.it autodiscover.justoverclock.it;
      listen 165.232.65.12 default_server;
        return 404; # managed by Certbot
    
    
    }
    
  • normally, the ssl parameter must be enabled on listening sockets in the server block

    Backup the conf file before and test that

    unfortunately I have to leave

  • normally, the ssl parameter must be enabled on listening sockets in the server block

    Backup the conf file before and test that

    unfortunately I have to leave

    @downpw not work

  • @justoverclock I can get to this in around an hour

  • @justoverclock done, i’ve removed that line and works again

    @phenomlab fixed it, removed the two lines and all works again

  • @justoverclock done, i’ve removed that line and works again

    @phenomlab fixed it, removed the two lines and all works again

    @justoverclock good 😁

    What caused the issue ? Was something new added to nginx.conf ?

  • @justoverclock you should also change this line

    client_max_body_size 5G;
    

    That could expose your server to a denial of service if someone decides to upload that large a file.

  • @justoverclock

    this line ?

        ssl_certificate /home/justoverclock/ssl.combined;
        ssl_certificate_key /home/justoverclock/ssl.key;
    
  • @justoverclock

    this line ?

        ssl_certificate /home/justoverclock/ssl.combined;
        ssl_certificate_key /home/justoverclock/ssl.key;
    

    @downpw yep exactly

  • @justoverclock those two lines

    ssl_certificate /etc/letsencrypt/live/justoverclock.it-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/justoverclock.it-0001/privkey.pem; # managed by Certbot
    

    Are issued by certbot, but aren’t normally positioned in the server block. Very odd.

  • phenomlabundefined phenomlab has marked this topic as solved on
  • hello guys again, something odd happened today, i’ve noticed that my website was down, it show

    err connection refused
    

    i’ve tried to restart nginx but i get some error that i’m not understand…

    root@:~# sudo service nginx restart
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    root@:~# sudo service nginx start
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    
    Jan 22 14:22:43 justoverclock.it systemd[1]: Starting A high performance web server and a reverse proxy server>
    Jan 22 14:22:43 justoverclock.it nginx[2386]: nginx: [emerg] "ssl_certificate" directive is not allowed here i>
    Jan 22 14:22:43 justoverclock.it nginx[2386]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Jan 22 14:22:43 justoverclock.it systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAIL>
    Jan 22 14:22:43 justoverclock.it systemd[1]: nginx.service: Failed with result 'exit-code'.
    Jan 22 14:22:43 justoverclock.it systemd[1]: Failed to start A high performance web server and a reverse proxy
    

    @justoverclock
    I have not yet gone through the comments to see what they answered you,
    But never restart Nginx before checking that all the blocks are working properly (this is how you check: sudo nginx -t)
    When nginx is restarted with an error it causes all sites (error 521) to shut down until the fault is resolved.
    If the test passed successfully you can restart Nginx (how to run: sudo systemctl reload nginx)

  • @justoverclock
    I have not yet gone through the comments to see what they answered you,
    But never restart Nginx before checking that all the blocks are working properly (this is how you check: sudo nginx -t)
    When nginx is restarted with an error it causes all sites (error 521) to shut down until the fault is resolved.
    If the test passed successfully you can restart Nginx (how to run: sudo systemctl reload nginx)

    @elhana-fine Also worth noting that nginx -t is not disruptive, and will not cause your sites to go offline in the event that the test fails.

  • @elhana-fine Also worth noting that nginx -t is not disruptive, and will not cause your sites to go offline in the event that the test fails.

    @phenomlab
    I am writing this from past experience.
    Whenever the test failed, all sites on the server were shut down (and returned error 521/502)
    Maybe I’m wrong, I write my experiences

  • @phenomlab
    I am writing this from past experience.
    Whenever the test failed, all sites on the server were shut down (and returned error 521/502)
    Maybe I’m wrong, I write my experiences

    @elhana-fine Interesting. That shouldn’t happen with a test. It’s supposed to be a dry run.

  • @elhana-fine Interesting. That shouldn’t happen with a test. It’s supposed to be a dry run.

    @phenomlab
    I mean when the test failed and I restarted the nginx with the error (sudo systemctl reload nginx)
    Apparently an error in one block in Nginx affects all blocks.

  • @phenomlab
    I mean when the test failed and I restarted the nginx with the error (sudo systemctl reload nginx)
    Apparently an error in one block in Nginx affects all blocks.

    @elhana-fine Yes that will happen of course if you still choose to restart the NGINX service after making a change and the test fails. The test on it’s own will state the error and the line number allowing you to fix that first 🙂


Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • Getting Eror When Started NodeBB

    Solved Configure bug
    7
    1
    2 Votes
    7 Posts
    1k Views
    @phenomlab yes i did. i deleted one of plugin then it started to work normally.
  • 0 Votes
    4 Posts
    1k Views
    @DownPW most of this really depends on your desired security model. In all cases with firewalls, less is always more, although it’s never as clear cut as that, and there are always bespoke ports you’ll need to open periodically. Heztner’s DDoS protection is superior, and I know they have invested a lot of time, effort, and money into making it extremely effective. However, if you consider that the largest ever DDoS attack hit Cloudflare at 71m rps (and they were able to deflect it), and each attack can last anywhere between 8-24 hours which really depends on how determined the attacker(s) is/are, you can never be fully prepared - nor can you trace it’s true origin. DDoS attacks by their nature (Distributed Denial of Service) are conducted by large numbers of devices whom have become part of a “bot army” - and in most cases, the owners of these devices are blissfully unaware that they have been attacked and are under command and control from a nefarious resource. Given that the attacks originate from multiple sources, this allows the real attacker to observe from a distance whilst concealing their own identity and origin in the process. If you consider the desired effect of DDoS, it is not an attempt to access ports that are typically closed, but to flood (and eventually overwhelm) the target (such as a website) with millions of requests per second in an attempt to force it offline. Victims of DDoS attacks are often financial services for example, with either extortion or financial gain being the primary objective - in other words, pay for the originator to stop the attack. It’s even possible to get DDoS as a service these days - with a credit card, a few clicks of a mouse and a target IP, you can have your own proxy campaign running in minutes which typically involves “booters” or “stressers” - see below for more https://heimdalsecurity.com/blog/ddos-as-a-service-attacks-what-are-they-and-how-do-they-work @DownPW said in Setting for high load and prevent DDoS (sysctl, iptables, crowdsec or other): in short if you have any advice to give to secure the best. It’s not just about DDos or firewalls. There are a number of vulnerabilities on all systems that if not patched, will expose that same system to exploit. One of my favourite online testers which does a lot more than most basic ones is below https://www.immuniweb.com/websec/ I’d start with the findings reported here and use that to branch outwards.
  • Is nginx necessary to use?

    Moved Solved Hosting nginx web
    2
    1 Votes
    2 Posts
    927 Views
    @Panda said in Cloudflare bot fight mode and Google search: Basic question again, is nginx necessary to use? No, but you’d need something at least to handle the inbound requests, so you could use Apache, NGINX, Caddy… (there are plenty of them, but I tend to prefer NGINX) @Panda said in Cloudflare bot fight mode and Google search: Do these two sites need to be attached to different ports, and the ports put in the DNS record? No. They will both use ports 80 (HTTP) and 443 (HTTPS) by default. @Panda said in Cloudflare bot fight mode and Google search: Its not currently working, but how would the domain name know which of the two sites to resolve to without more info? Currently it only says the IP of the whole server. Yes, that’s correct. Domain routing is handled (for example) at the NGINX level, so whatever you have in DNS will be presented as the hostname, and NGINX will expect a match which once received, will then be forwarded onto the relevant destination. As an example, in your NGINX config, you could have (at a basic level used in reverse proxy mode - obviously, the IP addresses here are redacted and replaced with fakes). We assume you have created an A record in your DNS called “proxy” which resolves to 192.206.28.1, so fully qualified, will be proxy.sudonix.org in this case. The web browser requests this site, which is in turn received by NGINX and matches the below config server { server_name proxy.sudonix.org; listen 192.206.28.1; root /home/sudonix.org/domains/proxy.sudonix.org/ogproxy; index index.php index.htm index.html; access_log /var/log/virtualmin/proxy.sudonix.org_access_log; error_log /var/log/virtualmin/proxy.sudonix.org_error_log; location / { proxy_set_header Access-Control-Allow-Origin *; proxy_set_header Host $host; proxy_pass http://localhost:2000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Api-Key $http_x_api_key; } location /images { index index.php index.htm index.html; root /home/sudonix.org/domains/proxy.sudonix.org/ogproxy; } fastcgi_split_path_info "^(.+\.php)(/.+)$"; listen 192.206.28.1:443 ssl http2; ssl_certificate /home/sudonix.org/domains/proxy.sudonix.org/ssl.combined; ssl_certificate_key /home/sudonix.org/ssl.key; } The important part here is server_name proxy.sudonix.org; as this is used to “map” the request to the actual domain name, which you can see in the root section as root /home/sudonix.org/domains/proxy.sudonix.org/ogproxy; As the DNS record you specified matches this hostname, NGINX then knows what to do with the request when it receives it.
  • Removing blue 'moved' tag from post

    Solved Configure nodebb
    16
    2
    3 Votes
    16 Posts
    3k Views
    @phenomlab Ah, got it working! I reversed the CSS addition to put z index high, and then I could see another error box saying fork title must be at least 3 characters. So made the new fork title longer and button responded.
  • 14 Votes
    69 Posts
    28k Views
    @phenomlab Seems to be better with some scaling fix for redis on redis.conf. I haven’t seen the message yet since the changes I made # I increase it to the value of /proc/sys/net/core/somaxconn tcp-backlog 4096 # I'm uncommenting because it can slow down Redis. Uncommented by default !!!!!!!!!!!!!!!!!!! #save 900 1 #save 300 10 #save 60 10000 If you have other Redis optimizations. I take all your advice https://severalnines.com/blog/performance-tuning-redis/
  • Is there any way to disable 'register' on the login page?

    Solved Configure
    8
    3 Votes
    8 Posts
    2k Views
    @qwinter yep, knew it was there somewhere
  • IRC Server/Client - Chat App with NodeBB

    Linux nodebb irc server client
    6
    1 Votes
    6 Posts
    2k Views
    @Hari not sure from the consumer perspective, but Skype has been all but completely consumed by Microsoft Teams when it comes to business usage.
  • nginx seo urls

    Solved Configure
    15
    3 Votes
    15 Posts
    3k Views
    @riekmedia that looks fine to me