I’m trying to configure Apache as a reverse proxy to handle 302 redirects from my backend servers internally. The goal is to prevent clients from seeing the redirect URLs and keep certain backend services hidden from external access.
My Setup
I have two internal web services running on ports 6666 and 7777 that aren’t accessible from outside. Apache runs on ports 80/443 and acts as a reverse proxy, routing requests for service_one.example.com and service_two.example.com to the respective backend services.
Current Flow
- Client requests service_one.example.com/page
- Apache forwards to backend service on port 6666
- Backend responds with 302 redirect to service_two.example.com/data/auth_key
- Apache passes 302 back to client
- Client makes new request to service_two.example.com/data/auth_key
- Apache forwards to second backend service
The Problem
I need to hide the redirect URL (service_two.example.com/data/auth_key) from clients and keep the second backend service completely internal. The first service can’t handle the request directly because the response from the second service could be large and time-consuming.
Is there a way to configure Apache to intercept 302 responses and handle them internally without sending the redirect back to the client? I need Apache to automatically follow the redirect and return the final response as if it came from the original request.