Docker Community Forums

Share and learn in the Docker community.

How to redirect path based request from Apache reverse proxy container to underline applications containers


(Sonalishah) #1

Hello Everyone…
I am newbie in docker, I was trying to understand & implement apache reverse proxy on one container and pass the request to application containers respectively

I have one AWS EC2 machine, on which I have installed docker. Now I have 3 containers running.i,e Apache reverse proxy container, and two app containers. I have bound apache container port with my EC2 machine’s port 80 and App1 and App2 are bounded in 8080 and 8081 respectively on the Host machine. Also, I have register one domain and it is attached to my EC2 machine.
Currently domain-name:8080/info.php this is working, it is redirecting to my App1 container
domain-name:8081/info.php this is redirecting to App2 container.
All the Proxy configuration is done correctly. From my reverse proxy container, I am able to ping other two app containers and access the application.But I am not able to route the external request from apache (reverse proxy )container to my respective app containers

Right Now I access application domain-name:8080/info.php (i.e port based redirection :8080/info.php)
Depending upon port it is redirecting to apps container. It is not passing through the reverse proxy container.Hence I want to implement Path-based redirection
http://domain-name/abc This should reach client1 container’s app
http://domain-name/pqr This should reach client2 container’s app

Stuck with the path based routing.I have tried using Apache rewrite module but don’t know whether it is a correct way to implement also read about HAproxy container

(Sam) #2

i can’t answer specifically , but how would you do this path routing with physical systems?

you do it exactly the same way with docker containers.

(Sonalishah) #3

Hi Sdetwell,

I was referring to apache rewrite module, where we need to specify the rewrite rule in .htaccess file.This is working, if my application is hosted in the same container.Here My application is hosted in different container. It is not within my apache reverse proxy container. So how should I write rewrite rule in my apache reverse proxy container’s conf file to route requests to my different app container.

If you can find any blog or somebody would have posted this kind of questions
As per my findings, I think I need to use HAProxy,

(Sam) #4

HAProxy is one way… I use this myself.

for the apache config… see