Alexi
(Alexi Coard)
August 24, 2016, 8:16am
1
Hi guys.
I have been trying out Caddy for a week and I would like to know if forwarding internal requests is possible.
I use a proxy like this :
192.168.100.26:2015 {
log stdout
errors stdout
bind {$ADDRESS}
proxy /minich 192.168.100.82:9000 {
transparent
without /minich
}
tls self_signed
}
The redirection works fine when I go to ip/minich I got what I want except for a few things : all the internal requests, for example /app/thumbs.png are not redirected too. It should be forwarded too to /minich/app/thumbs.png but they aren’t…
I have tried using the redir and rewrite directive with redir /minich /app 307
but I got an url such as /minich/minich/minich/…/app
Is there a way to do this in Caddy or is it server-side ?
Regards,
Alexi
abiosoft
(Abiola Ibrahim)
August 24, 2016, 11:53am
2
Looks like you want to proxy all requests instead. Why not get rid of the /minich
path ?
Can you list some request paths and expected proxy path maybe I can better understand what you are trying to achieve. e.g. /minich -> /
Alexi
(Alexi Coard)
August 24, 2016, 1:51pm
3
Thanks for the answer abiosoft, keeping /minich in the path is not mandatory.
The only thing I want is to have all the ressources
I have tried with the caddyfile I gave on the topic and I got this error
The request should be /minich/account/login but I don’t know how to proxy my http requests in Caddy (or if this is even possible)
Given your directive, where should I put this line ?
abiosoft
(Abiola Ibrahim)
August 24, 2016, 1:59pm
4
Looks like all you need is this
192.168.100.26:2015 {
log stdout
errors stdout
bind {$ADDRESS}
proxy /192.168.100.82:9000 {
transparent
}
tls self_signed
}
Alexi
(Alexi Coard)
August 24, 2016, 2:14pm
5
That doesn’t answer my question
I want to keep the proxy to /minich, I only want that internal requests such as the one I gave you are also forwarded (using rewrite or whatever)
For example a request wich normally goes to /app/thumbs.png to be automatically forwarded to /minich/app/thumbs.png using caddy
abiosoft
(Abiola Ibrahim)
August 24, 2016, 2:23pm
6
That is why I asked you to give some examples of request path and expected proxy path so I can fully get what you are trying to do.
E.g. the following requests should be proxied to what path upstream ?
/minich -> /
/app -> ?
/other -> ?
Alexi
(Alexi Coard)
August 24, 2016, 2:26pm
7
The following path should be proxied like this
/minich -> /192.168.100.82:9000 (as the proxy does I guess)
/app -> /minich/app
/other -> /minich/others
The /minich proxy is working, but then the others path (links etc) are not proxied
abiosoft
(Abiola Ibrahim)
August 24, 2016, 2:31pm
8
Try this
192.168.100.26:2015 {
log stdout
errors stdout
bind {$ADDRESS}
rewrite {
if {path} not_match ^\/minich #does not start with /minich
to /minich/{uri}
}
proxy /minich 192.168.100.82:9000 {
transparent
without /minich
}
tls self_signed
}
Alexi
(Alexi Coard)
August 24, 2016, 2:35pm
9
It works thanks abiosoft !
Best regards
1 Like
Alexi
(Alexi Coard)
August 24, 2016, 2:51pm
10
Just forgot to ask one thing, what if I want several rewrites ?
Using this CaddyFile :
192.168.100.26:2015 {
log stdout
errors stdout
bind {$ADDRESS}
rewrite {
if {path} not_match ^/minich #does not start with /minich
to /minich/{uri}
}
proxy /minich 192.168.92:9000 {
transparent
without /minich
}
proxy /something 192.168.100.82:9000 {
transparent
without /something
}
tls self_signed
}
Can I have the same thing working for both ?
abiosoft
(Abiola Ibrahim)
August 24, 2016, 2:57pm
11
You should be able to add another rewrite
block without issues. Can you elaborate on what you mean by several rewrites ?
Alexi
(Alexi Coard)
August 24, 2016, 3:03pm
12
Thanks for the reply.
For example, let’s imagine I have one URL per user, I have one client called minich and one called something, each one of these should be redirected to it’s own app.
I would like that each request is forwarded to other path without overwritting the ones from the other clients (which the previous answer does)
For example
/minich/{uri}
/something/{uri}
I cannot write a rewrite inside a proxy, and the user number is not supposed to be at only 2. SO is there an easy way to do this or do I need a regular expression for all the cases ?
abiosoft
(Abiola Ibrahim)
August 24, 2016, 3:07pm
13
How do we differentiate requests from different users. Does that mean requests meant for minich goes to /minich/...
and something goes to /something/...
respectively ?
Alexi
(Alexi Coard)
August 24, 2016, 3:16pm
14
Well I don’t really know, for the moment it is not implemented but is there a way to do this when I declare a new proxy directive ? like this
proxy /minich oneIP {
# rewrites here when you are in minich
}
proxy /something secondIP {
rewrites here when you are in something
}
Where all the links for a user are the same (they use a different instance of the app)
Alexi
(Alexi Coard)
August 25, 2016, 8:15am
16
But we can’t rewrites inside of a proxy directive, so I think I will have to use an other solution, thanks for the help
system
(system)
Closed
November 23, 2016, 8:15am
17
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.