caddy -version)?Caddy 0.9.3
I'm trying to make a simple proxy for the http endpoint on NSQ
Any data posted to the site root should be forwarded to the proxy url where the topic is defined
In the NSQ log files I can see that the request goes to the wrong address
localhost:8001
proxy / localhost:4151/pub?topic=caddy
Ran the binary, it read the CaddyFile
Proxy should forward the connection to the correct destination defined in the config
/pub?topic=caddy
NSQ got the query like this
/pub/?topic=caddy
If you want to use NSQ then just start NSQd and it will run with the default config. Monitor stdout.
When you say "latest" do you mean latest release or a commit? Please be specific, this project is in motion! For example, we have a recent commit, #1178, that may affect this issue.
Sorry, version added :) more motion!
That commit very well could solve this
Thanks! Do you have the ability to build from source? Perhaps you would have a chance to check it before I do (I have midterms for another week).
Not at the moment no, possibly next week.
With my limited testing #1178 4baca884c5e4767b114f3d363188e6570a24e90d does not seem to fix this issue, the extra / is still added to the forward-proxy url
Okay -- I think that was for a different issue (but still could have affected this one). So I guess we need to look into this one more.
I've looked at the code responsible & it seems to assume the proxy will be an upstream directory rather than a file. I will see if I can make progress
I need some discussion on expected behaviour.
Currently what happens is that the proxy is assumed to be a directory which can have first directories and then query parameters added to it.
so given
localhost:8001
proxy / localhost:4151/pub?topic=caddy
visiting localhost:8001 will add the extra / not desired to get localhost:4151/pub/?topic=caddy and I could just prevent this from happening.
However localhost:8001/pages/file.php?other=value will proxy to
localhost:4151/pub/pages/file.php?topic=caddy&other=value
where additional path items are added to the proxy path and additional query parameters are added to the query params.
The proxy works _correctly_ if you use a file ext.
localhost:8001
proxy / localhost:4151/pub.php?topic=caddy
then localhost:8001/pages/file.php?other=value will proxy to
localhost:4151/pub.php/pages/file.php?topic=caddy&other=value
now it is the pub.php file that will be executed by the server and the rest of the path can be retrieved through php environment variables.
So that gives a number of options.
/pages/file.php ?I'm sure there are other options I havent considered. Any suggestions?
I have created a pull request implementing option 3
@tobya Thanks so much for looking into this. I guess this is complicated; did we decide what we want to do, or how other web servers handle this?
Sorry I havent had time to continue this. The only complexity is deciding what to do. I don't really have access to other webservers at the moment.
If someone else wishes to take this up great, otherwise I'll try to get back to it soon.
From your comment on the PR it seems that the behaviour should stay the same except in the very spcific instance where there is no incoming path we should ensure an extra / is not added to the proxy url.
@tobya Awesome, thanks.
From your comment on the PR it seems that the behaviour should stay the same except in the very spcific instance where there is no incoming path we should ensure an extra / is not added to the proxy url.
... I think that sounds right. Now that we've defined the behavior we want to have, maybe this will be fairly simple.
Just added a pull request #1256 that doesnt fix but is the next step on the way.
My attempts to fix this have introduced unpredictable behaviour with paths. In my opinion
localhost:4151/pub?topic=caddy
and
localhost:4151/pub/?topic=caddy
should point to the same server resource.
Pretty sure this is fixed in v2 (since we rewrote it from scratch).