nginx - Nginx proxy_pass:是否可以在URL中添加静态参数?

标签 nginx

我想通过代理传递在URL中添加参数。
例如,我要添加一个apiKey:&apiKey = tiger
http://mywebsite.com/oneapi?field=22 ---> https://api.somewhere.com/?field=22&apiKey=tiger
您知道解决方案吗?

非常感谢,
吉尔斯。

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 - Nginx proxy_pass:是否可以在URL中添加静态参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16532293/

相关文章:

reactjs - 如何配置 NGINX 在同一个机器上提供 JSON API 和 React.js

javascript - 单页应用 Nginx Django Python 和端口转发

nginx - 打开() ""失败(2 : No such file or directory)

带有 ip 白名单的 nginx 维护页面

nginx - 仅使用 nginx 为特定域提供站点服务

docker - "host not found in upstream ..."使用 'kubectl apply -f' 但在 'docker-compose up' 中有效

ubuntu - 当我尝试安装 nginx 时未遇到的包

php - Nginx 和 WordPress 漂亮永久链接的 500 错误

java - nginx,为什么不能在if部分使用auth_request

python - nginx + uwsgi 502 Bad Gateway python