Wednesday, 23 April 2014
Use of ProxyPassMatch
So, what to do if you need make use of Regular Expression instead of simple prefix matching.
ProxyPassMatch ^(/.*\.phtml)$ http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com$1
As you see here, any match for .phtml file will be passed to another backend server.
Tuesday, 22 April 2014
Forwarding Requests to Another Server in Apache
I have a server on AWS which runs php5. Client requests are sent to this server as it sits behind the ELB. I also have another server which runs on php4 and isn't accessible publicly. So, in this case, Client requests for contents written in php4 can only be accessible via the php5 server. To solve this issue, I used ProxyPass and ProxyPassReverse in apache configuration.
ProxyPreserveHost On
ProxyPass /maps/ http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com/maps/
ProxyPassReverse /maps/ http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com/maps/
So, requests to URLs starting with /maps/ to be forward to the server http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com/maps/.
The ProxyPassReverse directive ensures that any redirect headers sent from the php4 server (in this case lt-legacy-1171567772.eu-west-1.elb.amazonaws.com) wil be modified so that they appear to come from the php5 main server.
As you can see, the php4 server isn't actually the aws server itself. It's the AWS ELB which forwards requests to the backend php4 server.
If your backend servers sit behind a firewall/Security Group, you would have to open ports (http in this case) for the frontend servers (php5 server in this case).
ProxyPreserveHost On
ProxyPass /maps/ http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com/maps/
ProxyPassReverse /maps/ http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com/maps/
So, requests to URLs starting with /maps/ to be forward to the server http://lt-legacy-1171567772.eu-west-1.elb.amazonaws.com/maps/.
The ProxyPassReverse directive ensures that any redirect headers sent from the php4 server (in this case lt-legacy-1171567772.eu-west-1.elb.amazonaws.com) wil be modified so that they appear to come from the php5 main server.
As you can see, the php4 server isn't actually the aws server itself. It's the AWS ELB which forwards requests to the backend php4 server.
If your backend servers sit behind a firewall/Security Group, you would have to open ports (http in this case) for the frontend servers (php5 server in this case).
Subscribe to:
Posts (Atom)