Programing

nginx가 포트 80을 수신하지 않음

lottogame 2020. 11. 23. 07:36
반응형

nginx가 포트 80을 수신하지 않음


난 그냥 제거, nginx를 1.2.7 우분투 12.04 서버를 설치 한 default에서 사이트 지원과로 내 자신의 파일을 추가 sites-available로와 심볼릭 링크 sites-enabled. 그런 다음 nginx를 다시 시작했습니다.

문제 : 그러나 URL로 이동해도 사이트가로드되지 않습니다. netstat -nlp | grep nginx그리고 netstat -nlp | grep 80모두가 어떤 결과를 반환하지 않습니다! lsof -i :80또한 아무것도 반환하지 않습니다. dig다른 서버의 A 가 올바른 IP 주소를 반환하므로 DNS 문제가 아닙니다. 이제 서비스를 중지 한 아파치에 연결할 수있었습니다. nginx 로그도 아무것도 표시하지 않습니다.

이 문제를 어떻게 해결해야합니까?

/etc/nginx/site-available/mysite.com

server {
    listen   80;
    server_name www.mysite.com mysite.com *.mysite.com;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    root /var/www/mysite/public;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_read_timeout 300;
    }

}

나는 이와 같은 문제가 있었고 해결책은 내 siteconf 파일을 올바르게 심볼릭 링크하지 않았다는 것입니다. 실행 해보십시오 vim /etc/nginx/sites-enabled/mysite.com— 갈 수 있습니까? 나는 "Permission Denied"를 받고 있었다.

실행되지 않는 경우 :

rm /etc/nginx/sites-enabled/mysite.com
ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/mysite.com

로그가 문제에 대해 침묵하는 경우 사이트 사용 디렉터리를 포함하지 않았을 수 있습니다. 사이트가로드되고 있음을 알리는 간단한 방법 중 하나는 서버 블록 내의 오류 / 액세스 로그 경로를 고유 한 경로로 설정하고 nginx를 다시로드 한 다음 파일이 생성되었는지 확인하는 것입니다.

다음 include 지시문이 /etc/nginx/nginx.conf의 http 컨텍스트 내에 있는지 확인하십시오.

http {
  ...
  include /etc/nginx/sites-enabled/*;
}

동일한 문제가 Failed to load resource: net::ERR_CONNECTION_REFUSED발생하여 HTTP를 통해 연결할 때 오류가 발생했지만 HTTPS에서는 문제가 없습니다. 실행 netstat -tulpn하고 nginx가 IPv4 용 포트 80에 바인딩되지 않는 것을 확인했습니다. 여기에 설명 된 모든 것을 완료했습니다. 매우 어리석은 것으로 밝혀졌습니다 .

가있는 sites-available파일 default_server이 실제로 활성화 되어 있는지 확인하십시오 .

이것이 다른 불쌍한 멍청이를 구하기를 바랍니다.


nginx를 포트 80에 두 번 바인딩하고있을 것입니다. 전체 구성 파일입니까? 포트 80을 수신하는 또 다른 진술이 없습니까?


다음 단계에 따라 nginx 디버깅에 접근하는 것이 도움이된다는 것을 알았습니다.

1 ... nginx가 실행 중인지 확인합니다.

ps aux | grep nginx

2 ... 해당 포트에 이미 바인딩 된 프로세스를 확인합니다.

lsof -n -i:80

3 ... nginx가 다시로드되었는지 확인합니다.

sudo nginx -t
sudo nginx -s reload

맥에서 brew services restart nginx입니다 하지 nginx를 다시로드하기에 충분.

4... Try creating simple responses manually to make sure your location path isn't messed up. This is especially helpful when problems arise while using proxy_pass to forward requests to other running apps.

location / {
    add_header Content-Type text/html;
    return 200 'Here I am!';
}

A semi-colon ; missing in /etc/nginx/nginx.conf for exemple on the line before include /etc/nginx/servers-enabled/*; can just bypass this intruction and nginx -t check will be successful anyway.

So just check that all instructions in /etc/nginx/nginx.conf are ended with a semi-colon ;.


Have you checked if your nginx binary really exists? please check if

#whereis nginx

outputs the binary path and check this path with your init script from /etc/init.d/nginx. e.g.

DAEMON=/usr/sbin/nginx

(In my init script "test -x $DAEMON || exit 0" is invoked and in any case this script returned nothing - my binary was completely missing)


In my case those network command's outputs showed nginx was correctly binding to port 80, yet the ports weren't externally accessible or visible with nmap.

While I suspected a firewall, it turns out that old iptables rules on the machine were redirecting traffic from those ports and conflicting with nginx. Use sudo iptables-save to view all currently applicable rules.

참고URL : https://stackoverflow.com/questions/16021481/nginx-not-listening-to-port-80

반응형