2017-11-15 3 views
0

백엔드는 localhost:8080에서 실행됩니다. 그리고 경로 /runFuction은 특정 명령을 실행합니다.nginx 프런트 엔드 및 백엔드 구성

이제 프론트 엔드 용 웹 서버로 nginx를 사용하고 백엔드에만 특정 요청을 보냈습니다. 나는이 가능할 것이다 어떻게 든 내가 뭔가를 놓친 거지 가정

... 
<form action="api/runFuction" method="post" enctype="multipart/form-data"> 
.... 
    <input type="submit" value="Do" /> 
</form> 

있는 형태를 가지고 내 index.html 사이트에서

server { 
    listen  80; 
    server_name localhost; 

    location/{ 
     root <path to site>; 
     index index.html index.htm; 
    } 
    location /api { 
    proxy_pass http://localhost:8080/; 
    } 
} 

을 다음과 같이

내의 nginx의 설정 보인다. 항상 404 page not there을 얻은 후 백엔드 경로에 어떻게 도달 할 수 있습니까?

답변

1

시도해 볼 수 있습니까?

location /api/ { 
    rewrite ^/api^/ /$1 break; 
    proxy_pass http://localhost:8080; 
} 
+0

고맙습니다. 왜 항상이 작은 실수입니까? 나는 그것을 정정하는 정규식이라고 생각한다. –