前提・実現したいこと
Nginxを用いて外部ホスト(サーバー)とのリバースプロキシのようなものを実現しようとしています。
外部(curl)--POST(json)-->[Nginx]--POST(json)-->外部ホスト(サーバー)
しかしうまく受け渡しができず困っています。
(Nginxと同じホスト(IP)での受け渡しは可能だったのに)
何か具体的案を頂ければ幸いです。。。。
発生している問題・エラーメッセージ
curl http://[Nginx] -X POST - H "Content-Type: application/json" -d "{"key":"value"}" したところ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p> がでてきました。 また、受け側の外部ホスト(サーバー)では 13.230.145.141 - - [04/Sep/2019 04:55:45] "POST /test1 HTTP/1.0" 404 - が出てきてPOSTしたJSONデータが欠如しているのかもしれないと考えています。
Nginxのdefault.conf
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } location ~^/test1$ { if ($request_method !~ ^(POST)$ ) { return 405; } proxy_request_buffering off; proxy_pass http://[外部ホスト]; proxy_redirect default; }
試したこと
Nginxと同じホスト(ローカル)環境ではJSONの受け渡しは確認
あなたの回答
tips
プレビュー