nginx proxy_pass by query param(query url) example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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