nGINX サーバーを実行しています。着信要求からカスタム HTTP ヘッダーを読み取り、別のアプリケーション サーバーにリダイレクトしたいと考えています。私は同様の質問を検索しましたが、カスタムヘッダーの作成については見つかりましたが、読み方については見つかりませんでした..
ヘッダーがこれで設定されている場合 -> "version = Version 1.0" その後、別のアプリケーションをリダイレクトする必要があります (uwsgi_pass xxxx:80 など)。
「バージョン = バージョン 2.0」に設定されている場合は、(uwsgi_pass xxxx:99) にリダイレクトする必要があります。
nginx.conf ファイルで試しました
server{
listen 80;
server_name xyz.com;
if ($http_version ~ 'Version 1.0') {
proxy_pass http://192.168.0.116:99/calc;
}
if ($http_version ~ 'Version 2.0') {
proxy_pass http://192.168.0.116:99;
}
location /hello {
proxy_pass http://192.168.0.116:99/calc;
}
}
nGINX を再起動するとエラーが発生します
nginx: [emerg] "proxy_pass" directive is not allowed here in /etc/nginx/nginx.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed