Proxy requests to another app on localhost
Problem Summary
My server runs 2 independent apps:
-
Laravel for user registration and authentication. This is exposed to the public.
-
Some other app, let's say a python server. This is only accessible on localhost, but it is not exposed to the public.
Goal: allow authenticated users to view the localhost app via Laravel.
Questions
-
What is the minimum Laravel setup required to get this to work?
-
What should the routes look like?
The request flow looks something like this:
-
User visits http://example.com/app
-
Laravel checks if user is authenticated
-
If user is not authenticated, redirect to http://example.com/login
-
If user is authenticated, proxy the request to http://localhost:1234/my-app and return the response back to the user.
-
When the localhost app requests
/my-app/resource.jpgLaravel should fetch it from http://localhost:1234/my-app/resource.jpg but the user will see it at http://example.com/app/resource.jpg
Please or to participate in this conversation.