nginx가 실행 중이지만 서비스를 제공하지 않습니까?

nginx가 실행 중이지만 서비스를 제공하지 않습니까?

나는 부두에 대한 프록시로 nginx를 설정하려고 노력해 왔습니다. 우분투 서버를 실행하는 노트북이 하나 있습니다. 이제 나는 localhost:8080에서 작업하는 부두를 만들었고 그것은 에서 앱의 홈 페이지를 제공합니다 http://192.168.1.5:8080/my-webapp-0.1.0-standalone/.

나는 다음과 같이 nginx를 구성했습니다 (이 페이지에서 적용했습니다):

server {
  listen 80;
  server_name nomilkfor.me;
  rewrite ^(.+?)/?$ http://nomilkfor.me$1 permanent;
}

server {
  listen 80;
  server_name www.nomilkfor.me;
  root /usr/share/nginx/html;

  location / {
    try_files $uri @my-webapp;
  }

  location @my-webapp {
    proxy_pass http://localhost:8080;
  }
}

그리고 홈 네트워크에서 nginx에 연결할 수 있으며 nginx 시작 화면이 표시됩니다.

나도 시도했다$ sudo netstat -tanpl|grep nginx

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3264/nginx: worker 

nginx가 포트 80에서 수신 대기하고 있는 것을 확인했습니다.

하지만 nomilkfor.me를 로드하려고 하면 'Chrome에서 nomilkfor.me에 연결할 수 없습니다.' 오류가 표시됩니다.

내가 도대체 ​​뭘 잘못하고있는 겁니까?



편집하다

저는 매우 간단한 구성을 만들었고 이 구성도 부두를 통해 앱 대신 index.html에 서버를 제공합니다./usr/share/nginx/

server {
    listen 80;
    server_name nomilkfor.me;

    # access_log /var/log/nginx/localhost.access.log;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }

    location /html { 
        root /usr/share/nginx/;
    }
}


편집 2

nginx가 생각보다 다른 conf 파일을 사용하고 있는 것 같습니다. conf 파일에 오타를 추가하고 /etc/nginx/sites-available/nomilkfor.me(닫는 중괄호를 제거했습니다) 실행했고 $ nginx -s reload오류 없이 컴파일되었으며 브라우저에 nginx 스플래시 페이지가 표시되었습니다. 어딘가에 다른 conf 파일이 있을 수 있나요? nginx가 사용하는 conf 파일을 찾는 방법이 있습니까?



편집 3

에 따라파지스 댓글추가했지만 root정확히 어디에 있어야 하는지, 무엇이어야 하는지 잘 모르겠습니다. 몇 가지 제안을 추가했습니다. 어느 것이 맞나요? /usr/share/nginx/html내가 가지고 있는 곳은 입니다 index.html.

server {
    listen 80;
    server_name nomilkfor.me;
    # root /home/z/jetty/jetty-dist/webapps
      root /usr/share/nginx/html;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }

    #location /html {
    #    root /usr/share/nginx/;
    }
}


편집 4

이것은 내 부두 conf 파일입니다. 그것은에있다/home/z/jetty/jetty-dist/jetty-distribution-9.1.0.v20131115/demo-base/webapps/my-webapp.xml

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Required minimal context configuration :                        -->
  <!--  + contextPath                                                  -->
  <!--  + war OR resourceBase                                          -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="contextPath">/test</Set>
  <Set name="war"><Property name="jetty.webapps" default="."/>/my-webapp-0.1.0-standalone.war</Set>

답변1

다음 단계를 시도해 볼 수 있나요?

  1. 상위 nginx 디렉터리의 nginx.conf 파일에 sites-available 디렉터리의 기본 파일을 가리키는 include 지시문이 있는지 확인하세요.

  2. 다른 서비스(예: jetty)로 프록시해야 하는 경우 아래 공유된 업스트림 옵션(sites-available/default 파일에 있음)을 사용하세요. 서버 섹션에서 업스트림을 참조할 수 있습니다.

기본 구성이 작동하면 다시 쓰기 옵션과 호스트 이름에 대해 수행해야 할 작업이 있는지 확인할 수 있습니다. 도움이 되길 바랍니다.

Nginx.conf:

include /etc/nginx/sites-enabled/*;

사이트 사용 가능 디렉터리(기본 파일):

upstream nomilkforme {  
        server 0.0.0.0:8080; ##nomilkforme running on 0.0.0.0:8080;
        keepalive 500;
}

server {
        listen       80;
        server_name  localhost;

        #access_log  logs/host.access.log  main;

        location / {
                proxy_redirect off;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;
                proxy_set_header X-Nginx-Proxy true;
                proxy_set_header Connection "";
                proxy_http_version 1.1;
                proxy_pass http://nomilkforme
        }

또한 다음과 같이 nginx conf 파일을 (다시 로드/다시 시작하기 전에) 확인할 수 있습니다. nginx -t -c /etc/nginx/nginx.conf

업데이트: nginx 구성을 시도했을 때 jetty가 0.0.0.0:8080에서 실행 중인지 확인할 수 있습니까(netstat를 사용하여 확인할 수도 있음). 또한, 브라우저를 통해 URL에 접속할 때 nginx의 접속/오류 로그를 공유할 수 있나요?

관련 정보