Я пытаюсь перенаправить запросы POST с помощью proxy_pass.
Вот моя полная конфигурация серверов (2 сервера):
# default server with all my subdomains
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name *.example.com;
passenger_enabled on;
rails_env production;
root /home/admin/rails/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# server to manage redirects
server {
listen 80;
server_name example.com;
# pages to redirect to apps.$host
location /app { return 301 $scheme://apps.$host; }
location /app/iphone { return 301 $scheme://apps.$host/iphone; }
location /legal/about { return 301 $scheme://apps.$host/legal/about; }
...
# pages to redirect to cloud or services
location /cloud/signup {
if ($request_method = GET) { return 301 $scheme://cloud.$host/home/new; }
if ($request_method = POST) {
proxy_pass $scheme://services.$host/users/create;
}
}
}
Когда я запускаю CURL POST:
curl -X POST --data '' http://example.com/cloud/signup?format=json
Я получаю 502 Bad Gateway.
Итак, я просмотрел журналы и увидел полное сообщение об ошибке:
2016/01/08 12:13:37 [ошибка] 20714 # 0: * 4 не определен преобразователь для разрешения services.example.com, клиент: 52.254.44.3, сервер: example.com, запрос: "POST / cloud / signup ? format = json HTTP / 1.1 ", хост:" example.com "
Обратите внимание, что мое перенаправление GET на services.example.com работает.
Что я пропустил в прокси?