nginx proxy_pass based on domain

Nginx supports multiple server blocks listening on the same port; this is how Virtual Hosts work; thus we simply proxy_pass virtual hosts to our desired target.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80;
server_name soundcloud.com;
location / {
proxy_pass http://soundcloud.com;
}
}
server {
listen 80;
server_name api.soundcloud.com;
location / {
proxy_pass http://api.soundcloud.com;
}
}

https://stackoverflow.com/questions/21064401/route-different-proxy-based-on-subdomain-request-in-nginx

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×