So, as you can see above, I have the āsameā path for the two proxies. I wanna know if itās possible to say to browser, wich /_next access based on wich url I entered. So if I entered project.com.br/project1, I would like to have access to project1.com.br/_next.
When you repeat the path matcher in a named matcher, itās the same as just doing path /project2 /_next/* which is an OR operation, either one or the other.
Are you saying the request paths look like /project1/_next/*? If so, then match with /project1* instead and it should work.
So really, Iām not clear on what you want to happen exactly. Please clarify (list out) exactly what requests you want to proxy to what destination.
Also, please fill out the help topic template. It saves time up front by asking many of the āchecklistā questions that need to answered so that weāre on the same page.
Iām sorry about not filling help template, it is because I donāt have those informations. The only thing I know is the version that is v2.1.
Basically Iām trying to run two nextJs application into 1 domain. So for every nextJs app, we have the routes and the /_next/* path where the chunks are located. My problem is: both projects have /_next/* path so, when I access a url that leads to project1 the requests made to render the page must come from project1 /_next/* and should work the same way for project2.
For example, following the informations that I said in my first message:
my domain is: https://project.com.br for example
Iām doing a reverse proxy of project1 and project2 to show those projects on https://project.com.br
Both projects, 1 and 2, are made using nextJs
NextJs uses /_next folder to store itās chunks
So, in project1 I have one /_next folder and in project2 I have another /_next folder
When I access https://project.com.br/project1 for example, what I need is that the /_next folder comes from project1 and if I access https://project.com.br/project2 I need that it comes from project2
I do not access https://project.com.br/project1/_next/*, what happens is: I access https://project.com.br/project1 and the browser get throught network those chunks from /_next in order to load the page and the browser get those chunks from https://project.com.br/_next. I wanna know if i can do something to say to the browser: 'hey you are in /project1 so you need to get the /_next from project1ā
Iām sorry man Iām really newbie in that kind of configs, I donāt really know how to explain properly
Thisāll be something you need to configure in your JS appās config. There should be a ābase pathā configuration that you can use to tell it to load assets from /project1/_next/ instead of simply /_next/.
Yeah, Iām trying using basePath for a while, but I donāt know how to set up on caddy, I mean, I would have /project1/_next/ but how would I do to have project.com.br/project1 instead of project.com.br/project1/project1? Letās suppose that I set up a basePath and I want to access /somepath, the url with basePath would be something like project1.com.br/project1/somepath and I want to access using project.com.br/somepath. I donāt know if I need to change the reverse_proxy or whatever.
Im my case if I set up a basePath, I would have something like that:
project1.com.br/project1/project1 where the first project1 is the basePath and the second one is the path.
project2.com.br/project2/project2 where the first project2 is the basePath and the second one is the path.
I need that to become project.com.br/project1 and project.com.br/project2 where project1 and project2 are the paths for the pages
Those paths that I used, /project1 and /project2 could be anything
Thatās not what I understood from your earlier questions.
In that case, all you need to do is:
rewrite * /project1{uri}
And Caddy will rewrite the path to add a prefix to it, which then your later request handlers will use.
But I donāt think thatās actually what you want, because then there would be no way to distinguish between requests destined for one project or the other.
So what you have to do is configure a base path, and notrewrite. The above rewrite adds a path prefix. Just donāt do that, and there wonāt be a second path prefix. Thatās it.
No. Caddy doesnāt need to care about /_next/* if you configured basepath, because that will guarantee that all the paths for your nextjs app use that basepath/prefix.
And FYI, /project1 would only match exactly /project1 and nothing else. Path matching is exact in Caddy, so you need to add the * to also match everything below that.
No. A request matcher looks at the incoming request and returns true or false on whether it should handle the request based on the configured rules. Request matchers donāt modify the request at all. Itās just a decision function.
If you made your request matcher /project1/somepath and requested /somepath, then the matcher would not match that path.
If you use the path matcher /project1* and make a request like /project1/somepath, then that would match, and Caddy would proxy that to https://project1.com.br/project1/somepath.
No, because that would make /_next/* ambiguous. You must disambiguate that somehow. And to do that, you need to configure nextjs in such a way that itās disambiguated.
I see, so itās not possible to distinguish the correct /_next depending only on the path some_path_from_project_1 for example. That was my initial question actually.
I saw a solution using NGINX, can I do something like that using Caddy?