Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse proxy returns "Empty reply from server" #285

Closed
davidt99 opened this issue Feb 2, 2020 · 3 comments
Closed

Reverse proxy returns "Empty reply from server" #285

davidt99 opened this issue Feb 2, 2020 · 3 comments
Assignees
Labels
Bug Bug report in proxy server

Comments

@davidt99
Copy link

davidt99 commented Feb 2, 2020

Describe the bug
I'm trying to use the reverse proxy plugin but I keep getting "Empty reply from server" from curl.

To Reproduce
Steps to reproduce the behavior:

  1. Run proxy --log-level d --hostname 0.0.0.0 --port 8899 --plugins proxy.plugin.ReverseProxyPlugin
  2. Run curl -v 0.0.0.0:8899/get
  3. curl is doing the TCP handshake but then hangs for few seconds and then yields: "Empty reply from server"

Expected behavior
The JSON that is returned from http://httpbin.org/get

Version information

  • OS: ubuntu 18.04
  • proxy.py: Version 2.1.2
  • python: 3.6.9 or 3.7.5

Additional context

proxy logs:

proxy --log-level d --hostname 0.0.0.0 --port 8899  --plugins proxy.plugin.ReverseProxyPlugin
2020-02-02 11:50:29,030 - pid:4282 [I] load_plugins:525 - Loaded plugin proxy.http.proxy.HttpProxyPlugin
2020-02-02 11:50:29,030 - pid:4282 [I] load_plugins:525 - Loaded plugin proxy.plugin.ReverseProxyPlugin
2020-02-02 11:50:29,030 - pid:4282 [I] listen:63 - Listening on 0.0.0.0:8899
2020-02-02 11:50:29,031 - pid:4282 [D] start_workers:81 - Started acceptor#0 process 4286
2020-02-02 11:50:29,033 - pid:4282 [D] start_workers:81 - Started acceptor#1 process 4287
2020-02-02 11:50:29,034 - pid:4282 [D] start_workers:81 - Started acceptor#2 process 4288
2020-02-02 11:50:29,035 - pid:4282 [D] start_workers:81 - Started acceptor#3 process 4289
2020-02-02 11:50:29,037 - pid:4282 [D] start_workers:81 - Started acceptor#4 process 4290
2020-02-02 11:50:29,038 - pid:4282 [D] start_workers:81 - Started acceptor#5 process 4291
2020-02-02 11:50:29,039 - pid:4282 [D] start_workers:81 - Started acceptor#6 process 4292
2020-02-02 11:50:29,041 - pid:4282 [D] start_workers:81 - Started acceptor#7 process 4293
2020-02-02 11:50:29,042 - pid:4282 [D] start_workers:81 - Started acceptor#8 process 4294
2020-02-02 11:50:29,044 - pid:4282 [D] start_workers:81 - Started acceptor#9 process 4295
2020-02-02 11:50:29,045 - pid:4282 [D] start_workers:81 - Started acceptor#10 process 4296
2020-02-02 11:50:29,047 - pid:4282 [D] start_workers:81 - Started acceptor#11 process 4297
2020-02-02 11:50:29,047 - pid:4282 [I] start_workers:84 - Started 12 workers
2020-02-02 11:50:31,384 - pid:4288 [D] initialize:145 - Handling connection <socket.socket fd=15, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('127.0.0.1', 8899), raddr=('127.0.0.1', 42290)>
2020-02-02 11:50:31,385 - pid:4288 [D] handle_readables:302 - Client is ready for reads, reading
2020-02-02 11:50:31,385 - pid:4288 [D] recv:65 - received 79 bytes from client
2020-02-02 11:50:41,398 - pid:4288 [D] run:402 - Client buffer is empty and maximum inactivity has reached between client and server connection, tearing down...
2020-02-02 11:50:41,399 - pid:4288 [D] shutdown:217 - Closing client connection <socket.socket fd=15, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('127.0.0.1', 8899), raddr=('127.0.0.1', 42290)> at address ('127.0.0.1', 42290) has buffer False
2020-02-02 11:50:41,399 - pid:4288 [D] shutdown:225 - Client connection shutdown successful
2020-02-02 11:50:41,399 - pid:4288 [D] shutdown:230 - Client connection closed

curl logs:

curl -v 0.0.0.0:8899/get
*   Trying 0.0.0.0...
* TCP_NODELAY set
* Connected to 0.0.0.0 (127.0.0.1) port 8899 (#0)
> GET /get HTTP/1.1
> Host: 0.0.0.0:8899
> User-Agent: curl/7.58.0
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host 0.0.0.0 left intact
curl: (52) Empty reply from server

@davidt99 davidt99 added the Bug Bug report in proxy server label Feb 2, 2020
abhinavsingh added a commit that referenced this issue Feb 2, 2020
@abhinavsingh
Copy link
Owner

Oops, we must also specify --enable-web-server flag to enable web server. Without which, proxy.py doesn't know how to handle incoming http server request and starts to treat them like http proxy requests, resulting into timeout.

Updated README.md to reflect the same. See #286

After @Benouare #272 , proxy.py will auto-detect and apply --enable-web-server flag when necessary.

@abhinavsingh
Copy link
Owner

@davidt99 Please re-open if problem persists. Thank you for reporting this!!!

abhinavsingh added a commit that referenced this issue Feb 2, 2020
@abhinavsingh
Copy link
Owner

abhinavsingh commented Oct 15, 2024

Please use --rewrite-host-header flag if you are using a http upstream. See latest commit #1492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug report in proxy server
Projects
None yet
Development

No branches or pull requests

2 participants