Question

Website Server Down 521

Posted December 14, 2021 206 views
NginxSecurityDNSUbuntu 20.04

After following the tutorial here, and successfully installing the origin certificate from cloudflare on my server, I got the 521 Error (web server is down). I tried accessing via droplet IP but I get ERRCONNECTIONREFUSED. I noticed this starts immediately after adding the Ngnix configuration. When I test for syntax errors in any of the Nginx configuration files, I find no problems.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi @ffadmin,

Can you please provide us with your Nginx configuration so that we’ll be able to check if there are any issues inside of it?

Additionally, if you turn of Cloudflare, does the error still persists?

Another thing, I would like you to check and let us know what it says inside, is your Nginx error.log. Turn on CloudFlare, add your Nginx configuration, once the error on your website appears, SSH to your droplet and type in:

tail -f /var/log/nginx/error.log

Then reload your website again and you should be able to see the error in your terminal.

  • Here is my Ngnix configuration

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    include /etc/nginx/modules-enabled/*.conf;

    events {
    workerconnections 768;
    # multi
    accept on;
    }

    http {

        ##
        # Basic Settings
        ##
    
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;
    
        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
    
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
    
        ##
        # SSL Settings
        ##
    
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;
    
        ##
        # Logging Settings
        ##
    
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
    
        ##
        # Gzip Settings
        ##
    
        gzip on;
    
        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    
        ##
        # Virtual Host Configs
        ##
    
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    

    }

    mail {

    # See sample authentication script at:

    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript

    # auth_http localhost/auth.php;

    # pop3_capabilities “TOP” “USER”;

    # imap_capabilities “IMAP4rev1” “UIDPLUS”;

    server {

    listen localhost:110;

    protocol pop3;

    proxy on;

    server {

    listen localhost:143;

    protocol imap;

    proxy on;

    • Hi @ffadmin,

      I think you’ve provided me with the Nginx configuration as a whole rather than the specific one for your website.

      Having said that, I see you’ve managed to resolve the issue, good to hear that. You mentioned at the beginning you installed Nginx wrong which lead to the issues. Can you let me know how did you install Nginx?

Connection refused error, might be issue with http ports

if you have locally installed SSL Certificate with Nginx, you might need to add that to Cloudflare and change the SSL settings in cloudflare.

Also make sure ports are open on the server 80/443

netstat -tulpn | grep LISTEN
  • Still not resolved after opening the ports

    • Please post the virtual host configuration file

      and also the output of this command

      tail /var/log/nginx/error.log
      
      • Here is the configuration

        server {
        listen 80;
        listen [::]:80;
        servername mydomain www.my_domain;
        return 302 https://$servername$requesturi;
        }
        server {

        # SSL configuration
        
            listen 443 ssl http2;
            listen [::]:443 ssl http2;
            ssl_certificate         /etc/ssl/cert.pem;
            ssl_certificate_key     /etc/ssl/key.pem;
        
            server_name my_domain www.my_domain;
        
            root /var/www/my_domain/html;
            index index.html index.htm index.nginx-debian.html;
        
            location / {
                    try_files $uri $uri/ =404;
            }
        

        }

        error log doesn’t contain any information

        • You need to set the SSL settings at cloudflare to Strict of Strict (FULL)

          depends on the SSL cert installed on your droplet

          if its valid cert then select Strict(full)
          if its self signed select Strict

        • I discovered the issue was from the way I installed Ngnix in the first place. I reinstalled Ngnix properly and the issue has been resolved. Thanks