2017-12-29 8 views
-1

Nginx 서버에서 실행중인 AngularJS 앱이 있습니다. Puma에서 실행중인 Rails API에 요청을 프록시 처리하려고합니다.Nginx proxy to Rails API

API에 대한 모든 요청을 다음과 같이하고 싶습니다. http://127.0.0.1/api/getTranslationLanguages 유닉스 소켓에서 수신하는 API 서버 (Puma)로 이동하십시오.

내 Nginx에의 설정 :

upstream api.development { 
    # Path to Puma SOCK file, as defined previously 
    server unix:/tmp/puma.sock fail_timeout=0; 
} 

server { 
    listen  80; 
    server_name localhost;   

    access_log logs/host.access.log; 
    rewrite_log on; 

    location/{ 
     root /path-to-app; 
     index index.html index.htm; 
     try_files $uri $uri/ /index.html =404; 
    }  

    location /api {   
     proxy_pass http://api.development; 
    } 
... 
} 

순간 미안에서 요청에서 404 오류가. 오류 로그 : 그것은 단지와 함께 일

Request URL:http://127.0.0.1/api/getTranslationLanguages 
Request Method:GET 
Status Code:404 Not Found 
Remote Address:127.0.0.1:80 
Referrer Policy:no-referrer-when-downgrade 

답변

-1

:

location /api {   
      rewrite ^/api(.*) /$1 break; 
      proxy_pass http://api.development; 
     } 
+0

내 대답을 향상은 서식이 댓글에 상처 입는 – ffeast