Nginx Config Need to Point Folder Reference Without Stripping
-
Now I'm sure that I'm a fool for not using Caddy which uses special mind probes to sense what my software will need and configure itself automatically, but let's just assume that I'm going to stick with Nginx. Here is what I am trying to figure out...
In my server block I have a "location / {}" already which is working fine.
Now I need a "location /api {}" block that goes to a ReactJS application that needs to think that it is processing the /api route. But for obvious reasons, this is stripped and there is no physical /api to point to. So I'm not sure how this would work.
-
I'm missing the obvious reasons. Why is there no where for /api to actually go?
-
@stacksofplates said in Nginx Config Need to Point Folder Reference Without Stripping:
I'm missing the obvious reasons. Why is there no where for /api to actually go?
Because, in this particular case, it's a Laravel route. It's dynamically generated in code.
-
So to give a concrete example...
I want requests going to / to be proxied to a service on another port. (This works in isolation.)
And I want requests going to /api to be sent to the correct folder. But the PHP in that folder (the Laravel public folder) needs to think that there is still an /api trailing so that it routes it correctly.
-
Couldn't you just use a rewrite for this? Not at a computer but like
rewrite ^/api /api
-
I've not used Laravel ever so that could be a dumb comment. I have no idea.
-
@stacksofplates said in Nginx Config Need to Point Folder Reference Without Stripping:
I've not used Laravel ever so that could be a dumb comment. I have no idea.
LOL
-
@stacksofplates said in Nginx Config Need to Point Folder Reference Without Stripping:
Couldn't you just use a rewrite for this? Not at a computer but like
rewrite ^/api /api
Maybe, I'll try it!