I am running a LEMP stack that was serving requests from both local and remote IP addresses, and now it's not serving requests at all. I was trying to set up virtual hosts on it when it stopped serving remote requests. I tried to fix this and now it's not serving local requests either. Whenever I try to access the website, from the LAN or the Internet, I get an error message that says (in Chrome): "This site can't be reached... ERR_CONNECTION_REFUSED"
I can ping the server's internal IP address, external IP address, and domain name, but I can't get the website to load. I'm also working on it via SSH, not directly on the machine. This is a configuration issue, not a networking issue.
Here is my website's config file: /etc/nginx/sites-available/anneliesephotos.com
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/nginx/ftp/lauren/anneliesephotos;
index index.php index.html index.htm index.nginx-debian.html;
server_name anneliesephotos.com;
# www.anneliesephotos.com;
#server_name 99.104.137.87;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
}
Here's what my /etc/nginx/sites-available/default file has:
server {
listen 80;
listen [::]:80;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}
When I look at the default file in Nano, the lines "expire max;", "log_not_found off;", and the closing curly brace on the next line after them have solid red blocks to the left of them, almost like an error.
This is what the /etc/nginx/nginx.conf file looks like:
user www-data;
worker_processes 2;
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;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie_6";
gzip_min_length 1100;
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 image/svg+xml
application/x-font-ttf font/opentype application/vnd.ms-fontobject;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.*;
}
/etc/nginx/sites-enabled has a symbolic link to the /etc/nginx/sites-available/anneliesephotos folder
lrwxrwxrwx 1 root root 42 Nov 24 02:44 anneliesephotos -> /etc/nginx/sites-available/anneliesephotos
When I run netstat -tlpn
, I see that for some reason port 80 isn't listening, despite the website's config file saying to do so:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 702/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1211/sshd
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1326/mysqld
tcp6 0 0 :::21 :::* LISTEN 1005/vsftpd
tcp6 0 0 :::22 :::* LISTEN 1211/sshd
When I run nginx -t
, I get this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
When I run service nginx status
, I get the following line, among others (none of which include "off" or "disabled"):
Active: active (running) since Sat 2018-11-24 10:47:48 UTC; 5h 38min ago
So I know that nginx is running, the syntax of the configuration files is correct, the config file for the particular website says to listen on port 80, and the config file is symlinked in /sites-enabled
ps | grep nginx
does not return any results. When I try to start nginx by entering/usr/sbin/nginx
, I don't get any errors, but I still don't get any results fromps | grep nginx
– Ethan Nov 26 '18 at 15:36ps aux | grep nginx
, there are 9 lines returned, 3 of which are master processes and the rest are worker processes.iptables -L
returns this:Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
– Ethan Nov 26 '18 at 16:58