Skip to content

Instantly share code, notes, and snippets.

@cuixin
Last active December 28, 2018 02:23
Embed
What would you like to do?
nginx proxy_pass by query param(query url) example
events {
}
http {
server {
listen 80;
server_name localhost;
location / {
set $host_1 "http://127.0.0.1:8881";
set $host_2 "http://127.0.0.1:8882";
set $cur_host "http://127.0.0.1:8888";
if ($args ~* (.*)(channel=android)(.*)) {
set $cur_host $host_1;
}
if ($args ~* (.*)(channel=ios)(.*)) {
set $cur_host $host_2;
}
proxy_pass $cur_host;
}
}
}
daemon off;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment