Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ixudra's avatar

Laravel instance behind reverse proxy

For my current Laravel 5 project, my client has provided a server which is "hidden" behind a reverse proxy. Which is all good as far as I'm concerned, but it seems that Laravel doesn't know how to handle this very well: ALL my routes no throw route not found exceptions, no matter what I do...

actual server IP: 100.0.7.xxx
reverse proxy IP: 200.0.7.xxx

What the reverse proxy also does, is add a suffix /project-name to the url. So to access the app, I need to do the following:

GET http://200.0.7.xxx/project-name/insert-route-here

Sadly, this doesn't appear to be working. Does anyone know exactly what is causing this and how I can fix this?

0 likes
4 replies
ixudra's avatar

So I did some more debugging and it turns out that the router tries to link the /project-name suffix to a route, which obviously does not exist. I guess what I would to is add a prefix to all my routes but I'd really rather not since this is only the case on one server and this will only be the case during development..

Any suggestions are very much appreciated

bobbybouwmann's avatar

Just an idea, why not use a route group with the suffix you need?

ixudra's avatar

@bobbybouwmann that's an option but I'd really rather not for reasons mentioned in my previous post. Also, I find that to be a rather dirty fix, I would much rather fix the underlying issue

donkfather's avatar

Am working on a smiliar project. The proxy can be configured to rewrite the url and send it to the app without the prefix but it didn't work for POST requests so i ended up duplicating my routes with and without prefix. I moved my routes to a _web.php and included that in the web.php in a group woth prefix and a second includ outside the group.

Please or to participate in this conversation.