Default nginx setup won't load page?

June 23, 2019 136 views
DigitalOcean Nginx Ubuntu 18.04

Hi all,

I’m new to DigitalOcean and new to nginx, so apologies if I’m missing something obvious. I’m trying to set up an nginx server for Ubuntu 18.04, and followed steps 1-3 in the DigitalOcean tutorial “How To Install Nginx on Ubuntu 18.04”. My terminal output matched the example output given in the tutorial, and systemctl status nginx returns

nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-06-23 02:46:54 UTC; 37min ago
Docs: man:nginx(8)
Process: 2356 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2345 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 2360 (nginx)
Tasks: 2 (limit: 1152)
CGroup: /system.slice/nginx.service
├─2360 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─2362 nginx: worker process

Additionally, /var/log/nginx/error.log is empty, so it appears that nginx is indeed running. However, when I try to navigate to my IP address, the browser hangs and eventually times out, instead of displaying the nginx welcome page. Do I need to edit nginx.conf? The tutorial made it sound like I wouldn’t need to.

Thanks!

Current nginx.conf:

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

events {
    worker_connections 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; # 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;
#   }
#}
2 Answers

Hello,

Indeed it should work with the default Nginx config. I believe that it might be a firewall issue.

To allow normal HTTP traffic to your Nginx server, use the Nginx HTTP profile with the following command:

sudo ufw allow ‘Nginx HTTP’

Hope that this helps!
Regards,
Bobby

Thanks, Bobby! It wasn’t that particular ufw setting that was the issue, but disabling the firewall did cause everything to start behaving normally, so I’ll switch my debug efforts to that direction.

Have another answer? Share your knowledge.