错误显示上游供应商应用程序。在我们的节点应用程序中写了一条路由来代理请求并避免了该错误,但无法使NGINX重写正常工作。我尝试过许多重写的变体,现在机智已尽。比实际代码花费更多的时间... =(
IN: /Txtranscription/transcription/TranscriptionHandler.ashx?q=c3R1ZHlfaWQ...
OUT: /Txtranscription/transcription/TranscriptionHandler.ashx?q=c3R1ZHlfaWQ...
EXPECTED: /transcription?encoded=c3R1ZHlfaWQ...
### override handling of /Txtranscription/transcription/TranscriptionHandler.ashx
location /Txtranscription/transcription/TranscriptionHandler.ashx {
add_header Access-Control-Allow-Origin $cors_header;
access_log logs/vapi.proxy.log lfupstream;
error_log logs/vapi.error.log error;
rewrite ^/Txtranscription/transcription/TranscriptionHandler\.ashx\?q=(.*)$ /transcription?encoded=$1 break;
proxy_pass http://vapi;
}
答案 0 :(得分:1)
您根本不需要重写请求,您可以在proxy_pass
指令后附加路径,Nginx会将原始请求URI中位置块的匹配部分替换为{ {1}}指令。
所以这应该起作用:
proxy_pass
答案 1 :(得分:0)
示例:
location ~ ^/connector(/?)(.*)$ {
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
proxy_set_header Authorization "";
set $upstream_endpoint http://YOUR-END-POINT/$2$is_args$args;
proxy_pass $upstream_endpoint;
}
魔术是->位置〜^ / admin (/?)(。*)$
然后-> / $ 2 $ is_args $ args;