Closed ssb-jnk closed 1 year ago
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
Can you provide a more complete example that shows the problem, and include your node and configurable-http-proxy version?
When I do:
configurable-http-proxy
curl -X POST http://localhost:8001/api/routes/api -d '{"target": "http://127.0.0.1:8888"}'
curl http://localhost:8000/api
I get the request proxied to 127.0.0.1:8888/api, as requested. There's no difference in the proxy logs for /api/
and /api
:
$ configurable-http-proxy
08:55:12.097 [ConfigProxy] warn: REST API is not authenticated.
08:55:12.107 [ConfigProxy] info: Proxying http://*:8000 to (no default)
08:55:12.107 [ConfigProxy] info: Proxy API at http://localhost:8001/api/routes
# curl -X POST http://localhost:8001/api/routes/api -d '{"target": "http://127.0.0.1:8888"}'
08:56:20.888 [ConfigProxy] info: Adding route /api -> http://127.0.0.1:8888
08:56:20.889 [ConfigProxy] info: Route added /api -> http://127.0.0.1:8888
08:56:20.893 [ConfigProxy] info: 201 POST /api/routes/api
# curl -X POST http://localhost:8001/api/routes/api/ -d '{"target": "http://127.0.0.1:8889"}'
09:00:04.466 [ConfigProxy] info: Adding route /api -> http://127.0.0.1:8889
09:00:04.466 [ConfigProxy] info: Route added /api -> http://127.0.0.1:8889
09:00:04.467 [ConfigProxy] info: 201 POST /api/routes/api/
Thanks for replying. Sure thing!
I use the latest version of chp( not configured anything ): https://hub.docker.com/r/jupyterhub/configurable-http-proxy I use the latest version (dummy api for testing): cloudkats/hello-world-rest
POST http://localhost:8001/api/routes/api
{
"target": "http://172.17.0.3:3000"
}
GET http://localhost:8001/api/routes
{
"/api": {
"target": "http://172.17.0.3:3000",
"last_activity": "2023-02-06T08:27:12.213Z"
}
}
GET http://localhost:8000/api/version
Error: No default engine was specified and no extension was provided.<br> at new View (/usr/src/app/node_modules/express/lib/view.js:61:11)<br> at Function.render (/usr/src/app/node_modules/express/lib/application.js:587:12)<br> at ServerResponse.render (/usr/src/app/node_modules/express/lib/response.js:1039:7)<br> at /usr/src/app/lib/app.js:61:19<br> at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)<br> at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:328:13)<br> at /usr/src/app/node_modules/express/lib/router/index.js:286:9<br> at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)<br> at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)<br> at /usr/src/app/lib/app.js:14:3
It appears that GET http://localhost:8000/api/version routes to http://172.17.0.3:3000/api/version and not http://172.17.0.3:3000/version. The reason i believe this is because if i add following route, then it works by accessing http://localhost:8000/version
{
"/": {
"target": "http://172.17.0.3:3000",
"last_activity": "2023-02-06T08:27:12.213Z"
}
}
It appears that GET http://localhost:8000/api/version routes to http://172.17.0.3:3000/api/version and not http://172.17.0.3:3000/version.
Yes, that is the intended behavior. If you don't want to preserve URL prefixes in the proxied request, I think you want to add --no-include-prefix
, which will strip the prefix from the URL before proxying.
Aha, so this is a typical PEBKAC issue, thanks for helping me out. Appreciate it!
Bug description
I have added /api to http://localhost:8001/api/routes and given the target http://172.17.0.2:8080, however when accessing it at http://localhost:8000/api i don't get expected result. However if i add '/' empty path to http://localhost:8001/api/routes and give it the same route then it works.
Expected behaviour
I expect /api to give me the JSON data provided by http://172.17.0.2:8080
Example:
{ "/api": { "target": "http://172.17.0.2:3000", "last_activity": "2023-02-05T17:07:49.205Z" }, }
should give "up'-- > curl http://172.17.0.2:8000/api/health
However if i add following and curl http://172.17.0.2:8000/health i get expected result:
{ "/": { "target": "http://172.17.0.2:3000", "last_activity": "2023-02-05T17:07:49.205Z" }, }