2017-12-29 37 views
-1

私はAngginJSアプリケーションをNginxサーバーで実行しています。私はPumaで動作するRails APIへのリクエストをプロキシしようとしています。Rails APIへのNginxプロキシのパス

APIのリクエストはすべて次のようにしてください:http://127.0.0.1/api/getTranslationLanguages UnixソケットでリッスンしているAPIサーバ(Puma)にアクセスしてください。

と私のnginxの設定ファイル: - 私は要求に404エラーを取得して瞬間

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; 
    } 
... 
} 

。 エラーログ:それだけで働いた

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

関連する問題