With nginx http directive, you can have multiple servers on the same port with different names:
server {
listen 80;
server_name server1.example.com;
location / {
proxy_pass http://server1.example.com;
}
}
server {
listen 80;
server_name server2.example.com;
location / {
proxy_pass http://server2.example.com;
}
}
Is it possible to have nginx proxy multiple mysql servers on the same port with different names like you can with http? They aren't part of a cluster or anything. The have different, unrelated tables.
stream {
upstream db1.example.com {
server db1.example.com:3306;
#server_name db1.example.com; "server_name" directive is not allowed here
}
upstream db2.example.com {
server db2.example.com:3306;
}
server {
listen 3306;
proxy_pass db1.example.com;
}
#duplicate "3306" address and port pair
#server { listen 3306; proxy_pass db2.example.com; }
}