Você pode modificar a configuração do servidor proxy nginx assim:
server {
server_name example.com;
listen 80;
location / {
proxy_pass http://127.0.0.1:3001;
}
location /foo {
proxy_pass http://127.0.0.1:3002;
}
}
server {
server_name example.org;
listen 80;
location / {
proxy_pass http://127.0.0.1:3003;
}
}
server {
server_name example.net;
listen 80;
return 301 http://example.com/foo;
}