Host names in 1.9

I’m having some difficulty using the stream directive in 1.9. I may be
using it wrong, so please correct me if this is incorrect or not
possible.

stream {
server {
listen 1520;
server_name customhost.example.com
proxy_pass db;
}
upstream db {
server 10.100.0.104:1523;
}
}

I have multiple host names (server_name s) that I want to hit 1520 and
be
proxied to different upstream dbs. I have a second stream context with
a
different server_name and different upstream db. I can’t get this to
work.
I think I’m missing something. How would I accomplish this? ultimate
goal:
reverse proxy a database connection based on host name.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,259144,259144#msg-259144

On Tue, May 26, 2015 at 06:47:19PM -0400, sentinel21 wrote:

Hi there,

I’m having some difficulty using the stream directive in 1.9. I may be
using it wrong, so please correct me if this is incorrect or not possible.

A connection comes to an ip:port.

A http connection includes a specific host name in a well-known place
in the request.

An arbitrary tcp connection does not.

stream {
server {
listen 1520;

Untested, but: listen on ip1:1520 here, and ip2:1520 in the next
server block; then have the different host names resolve to different
ip addresses.

I have multiple host names (server_name s) that I want to hit 1520 and be
proxied to different upstream dbs. I have a second stream context with a
different server_name and different upstream db. I can’t get this to work.
I think I’m missing something. How would I accomplish this? ultimate goal:
reverse proxy a database connection based on host name.

I can’t see any other way to achieve what you want, for a generic tcp
forwarder.

hostname is irrelevant - all nginx sees is the ip:port connected to.

f

Francis D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs