benoitc / tproxy

simple TCP routing proxy
Other
268 stars 38 forks source link

tproxy + nginx #1

Closed ghost closed 13 years ago

ghost commented 13 years ago

I wanted to use tproxy and nginx to serve static files. When I take my browser to tproxy url, most of the time the browser fail to show the page.

I got this in the console running tproxy with --log-level=debug

2011-05-10 23:04:17 [11337] [INFO] tproxy 0.5.3 started
2011-05-10 23:04:17 [11337] [INFO] Listening on 127.0.0.1:5000
2011-05-10 23:04:17 [11338] [INFO] Booting worker with pid: 11338
2011-05-10 23:21:07 [11338] [DEBUG] Successful connection to 127.0.0.1:8000
Traceback (most recent call last):
  File "/home/amirouche/ftv/hm2/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
TypeError: proxy_io() takes at most 4 arguments (5 given)
<Greenlet at 0x1eef160: <bound method Route.proxy_io of <tproxy.route.Route object at 0x1ed7c90>>(<socket at 0x1f61a10 fileno=15 sock=127.0.0.1:5000, <socket at 0x7fcf5f0081d0 fileno=16 sock=127.0.0.1, [], None)> failed with TypeError

2011-05-10 23:21:07 [11338] [DEBUG] got data from input
2011-05-10 23:21:07 [11338] [DEBUG] Close connection to 127.0.0.1:8000
2011-05-10 23:21:07 [11338] [DEBUG] Successful connection to 127.0.0.1:7999
Traceback (most recent call last):
  File "/home/amirouche/ftv/hm2/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
TypeError: proxy_io() takes at most 4 arguments (5 given)
<Greenlet at 0x1eef958: <bound method Route.proxy_io of <tproxy.route.Route object at 0x1ed7c90>>(<socket at 0x1f718d0 fileno=15 sock=127.0.0.1:5000, <socket at 0x1f79ed0 fileno=16 sock=127.0.0.1:5125, [], None)> failed with TypeError

2011-05-10 23:21:07 [11338] [DEBUG] Close connection to 127.0.0.1:7999```

To make things more clear at localhost:8000 there is gunicorn, and at 7999 there is nginx. 

here are the versions a used to do the test:```
gevent==0.13.6
greenlet==0.3.1
gunicorn==0.12.1
http-parser==0.3.3
-e git://github.com/benoitc/tproxy.git@0f32b5b0d8a1f004ed060db4729943b37a3306c1#egg=tproxy-dev
wsgiref==0.1.2```

there is an example setup at this repository https://bitbucket.org/abki/ftv/src.

I think it has to do something with nginx, since when I tried gunicorn+file served with tproxy (like in the readme example) it worked well.

I runned this tests on linux 2.6
ghost commented 13 years ago

now with 0.5.4 the exception is gone but the problem keeps happening i.e. the page doesn't show up sometimes.

I did look to nginx logs and stuff and find out (I'm refering to the test I've setup in https://bitbucket.org/abki/ftv/src ) : tproxy doesn't close the connection with nginx as we would expect, but some ms or sec after the initial request was fired. Until then, you can't try to fire up the page again it will result in a forbidden access error from nginx. Having a look at nginx logs I discovered that nginx is requested 3 times: 1) for the images I've put in the gunicron answer 2) for /favicon.ico which is strange since proxy.py filter by path and /favicon.ico is not in the right path 3) for « / » which is more strange actually

So I've hit a wall, I hope I did not do a stupid mistake in my configuration.

benoitc commented 13 years ago

You may need to close the connection with the remote if you want to have the route based on the path.

benoitc commented 13 years ago

closing this issue. Feel free to reopen it if the problem still happen.