in your upstream configuration you have ports defined ( 6666 and 9999 ), those are the ports your backend servers need to listen on
the proxy_pass directive doesn’t need an additional port configuration in this case.
Your nginx listens on port 81 which you’ve defined in the listen directive
Is this what you tried to do?
http {
#...
upstream upstream_1{
server 192.168.1.100:6666;
server 192.168.1.101:9999;
}
upstream upstream_2{
server 192.168.1.100:6661; // other backstream port if you use port 81
server 192.168.1.101:9991;
}
server {
listen 80;
#.....
location ~ /myapp {
proxy_pass http://upstream_1;
}
}
server {
listen 81;
#.....
location ~ /myapp {
proxy_pass http://upstream_2;
}
}
}