本文介绍了Nginx proxy_pass:是否可以在URL中添加静态参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过代理传递在URL中添加参数.例如,我要添加一个apiKey:& apiKey = tiger
http://mywebsite.com/oneapi?field=22 ---> https://api.somewhere.com/?field=22&apiKey=tiger 你知道解决方案吗?
I'd like to add a parameter in the URL in a proxy pass.For example, I want to add an apiKey : &apiKey=tiger
http://mywebsite.com/oneapi?field=22 ---> https://api.somewhere.com/?field=22&apiKey=tigerDo you know a solution ?
非常感谢,吉尔斯.
server {
listen 80;
server_name mywebsite.com;
location /oneapi{
proxy_pass https://api.somewhere.com/;
}
}
推荐答案
location = /oneapi {
set $args $args&apiKey=tiger;
proxy_pass https://api.somewhere.com;
}
这篇关于Nginx proxy_pass:是否可以在URL中添加静态参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!