dlundquist / sniproxy

Proxies incoming HTTP and TLS connections based on the hostname contained in the initial request of the TCP session.
BSD 2-Clause "Simplified" License
2.53k stars 397 forks source link

sniproxy listens on all IP4 #109

Closed pyheme closed 10 years ago

pyheme commented 10 years ago

Hi, I have a VPS with 2 associated IP4 addresses. I'm using sniproxy to redirect some personal traffic for specific websites and it does a great job at it!

My only issue is that, in sniproxy.conf, I specify which IP I'd like sniproxy to listen on so that I can have apache running on the same port on the other IP without interference.

listen 123.123.123.123:80 { proto http } [ I also tried 123.123.123.123 80 with same results.]

But sniproxy also listens on 123.123.123.124:80 (the other IP). Am I doing something wrong? Thanks in advance.

dlundquist commented 10 years ago

@pyheme It should bind to the address specified in the listen directive, defaulting in INADDR_ANY if only a port is specified. I just verified on one my boxes running the master. Could you verify with netstat?

dustin@gateway01:~$ grep listen /etc/sniproxy.conf
listen 67.214.208.74:80 {
listen 67.214.208.74:443 {
dustin@gateway01:~$ sudo netstat -lptn | grep sniproxy
tcp        0      0 67.214.208.74:80        0.0.0.0:*               LISTEN      31430/sniproxy  
tcp        0      0 67.214.208.74:443       0.0.0.0:*               LISTEN      31430/sniproxy  
dustin@gateway01:~$ sudo vi /etc/sniproxy.conf
dustin@gateway01:~$ grep listen /etc/sniproxy.conf
listen 80 {
listen 443 {
dustin@gateway01:~$ sudo service sniproxy restart
[....] Restarting HTTPS SNI proxy: sniproxyEnabling core dumps...
/tmp/core.%e.%u.%p
. ok 
dustin@gateway01:~$ sudo netstat -lptn | grep sniproxy
tcp6       0      0 :::80                   :::*                    LISTEN      31488/sniproxy  
tcp6       0      0 :::443                  :::*                    LISTEN      31488/sniproxy  

Additionally, could you confirm the addresses you have configured in the listen statement are actually assigned to an interface on the host (should be included in the output of ip address show)?

pyheme commented 10 years ago

Thanks. I checked netstat and it does say that sniproxy only listens on ports 80 and 443 of a specific IP but when I go to IP #2 in Chrome, it returns "Backend not available" instead of apache's homepage.

ip address show does show that each address is assigned to an interface (venet0:0 and venet0:1 respectively).

So my issue would be in my apache configuration?

Thanks,

dlundquist commented 10 years ago

@pyheme Could you email me the output of netstat -lptn, ip address show, your sniproxy config file and what version (git commit) you are running?

dlundquist commented 10 years ago

@pyheme Yes, it sounds like Apache is not bound to a specific IP. You need to use the Apache listen directive to bind it to specific IP.

See: http://httpd.apache.org/docs/2.4/bind.html