My server was working very fine until few hours ago, when somehow it stopped answering to calls,
I figured that the unicorn is working fine (curl localhost:3000 works - where 3000 is the port of unicorn)
I ran:
sudo netstat -anltp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5664/mysqld
tcp 0 0 my.public.ip.address:80 0.0.0.0:* LISTEN 6825/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2737/sshd
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 6389/unicorn.rb -E
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 2934/master
tcp 0 0 my.public.ip.address:443 0.0.0.0:* LISTEN 6825/nginx
tcp 0 0 my.public.ip.address:22 a.different.ip.number:49372 ESTABLISHED 3433/sshd: user
tcp 0 232 my.public.ip.address:22 a.different.ip.number:49909 ESTABLISHED 6887/sshd: user
tcp6 0 0 :::22 :::* LISTEN 2737/sshd
tcp6 0 0 :::25 :::* LISTEN 2934/master
where it seems that both port 80 and port 443 are open by nginx, but when I try to curl the localhost:
$ curl localhost
curl: (7) Failed connect to localhost:80; Connection refused
$ curl https://localhost
curl: (7) Failed connect to localhost:443; Connection refused
the port 22 used by ssh seems to be working fine. as I'm logged on the box via ssh:
this is my /etc/nginx/nginx.conf
file:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/app/nginx_access.log;
error_log /var/log/app/nginx_error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
here is my /etc/nginx/sites-enabled/app
file:
upstream unicorn {
server 0.0.0.0:3000 fail_timeout=0;
}
server {
listen my.ip.num.ber:80;
server_name www.mydomainname.com;
location / {
rewrite ^ https://$server_name$request_uri permanent;
}
}
server {
listen my.ip.num.ber:443 ssl;
server_name www.mydomainname.com;
client_max_body_size 4G;
keepalive_timeout 5;
root /var/www/mydomainname/releases/20140417140248/public/;
try_files $uri $uri/index.html $uri.html @unicorn;
ssl_certificate /srv/ssl/mydomainname.chained.crt;
ssl_certificate_key /srv/ssl/mydomainname.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
# alias /var/www/mydomainname/releases/20140417140248/public/;
}
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_intercept_errors on;
proxy_pass http://unicorn;
}
}
from a scan with nmap I see:
$ sudo nmap -sS -O 127.0.0.1
Starting Nmap 6.40 ( http://nmap.org ) at 2014-04-17 14:44 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000062s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
3000/tcp open ppp
3306/tcp open mysql
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=6.40%E=4%D=4/17%OT=22%CT=1%CU=30717%PV=N%DS=0%DC=L%G=Y%TM=534FE8C
OS:8%P=x86_64-unknown-linux-gnu)SEQ(SP=107%GCD=1%ISR=10B%TI=Z%CI=I%II=I%TS=
OS:8)OPS(O1=MFFD7ST11NW7%O2=MFFD7ST11NW7%O3=MFFD7NNT11NW7%O4=MFFD7ST11NW7%O
OS:5=MFFD7ST11NW7%O6=MFFD7ST11)WIN(W1=AAAA%W2=AAAA%W3=AAAA%W4=AAAA%W5=AAAA%
OS:W6=AAAA)ECN(R=Y%DF=Y%T=40%W=AAAA%O=MFFD7NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%
OS:S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%
OS:RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W
OS:=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
OS:U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%D
OS:FI=N%T=40%CD=S)
Network Distance: 0 hops
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.27 seconds
any clues?
thanks
Addition:
after restarting with nginx configured with listen 80
and listen 443
, here's my new netstat:
sudo netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5664/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7845/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2737/sshd
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 6389/unicorn.rb -E
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 2934/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 7845/nginx
tcp6 0 0 :::22 :::* LISTEN 2737/sshd
tcp6 0 0 :::25 :::* LISTEN 2934/master
udp 0 0 0.0.0.0:57284 0.0.0.0:* 2418/dhclient
udp 0 0 0.0.0.0:68 0.0.0.0:* 2418/dhclient
udp 0 0 my.public.ip.addr:123 0.0.0.0:* 3550/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 3550/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 3550/ntpd
udp6 0 0 :::55187 :::* 2418/dhclient
udp6 0 0 ::1:123 :::* 3550/ntpd
udp6 0 0 :::123 :::* 3550/ntpd
It turns out that the DNS configuration went mad and pointed my domain to somewhere else. I fixed the DNS so the site will come back soon.
thanks