the power of mod_proxy proxy servers, load balancers and how to implement with apache http server

26
The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server.

Upload: tyrone-harrington

Post on 12-Jan-2016

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

The Power of mod_proxy

Proxy servers, load balancers and how to implement with Apache HTTP Server.

Page 2: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Hello World

• Paul Weinstein

• Web Programmer/Analyst at Orbit Media Studios, Inc.

Page 3: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Proxy Servers

Page 4: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Proxy Servers

What is a Proxy Server?

When Might a Proxy Server Be Useful?

How to Implement a Proxy Server with Apache HTTP Server?

Page 5: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

What is a Proxy Server?

“A server that acts as an intermediary for requests from clients seeking resources from other servers.”1

1 From Wikipedia, http://en.wikipedia.org/wiki/Proxy_server

Page 6: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might a Proxy Server Be Useful?

“To provide Internet access to internal clients that are otherwise restricted by a firewall.”

“The proxy can also use caching to reduce network usage.”2

2 Apache Module mod_proxy Documentation, http://httpd.apache.org/docs/2.1/mod/mod_proxy.html

Page 7: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might a Proxy Server Be Useful?

Page 8: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might a Proxy Server Be Useful?

“To provide Internet users access to a server that is behind a firewall.”

“Provide caching for a slower back-end server.”

“Be used simply to bring several servers into the same URL space”

“Be used to balance load among several back-end servers.” 2

2, Apache Module mod_proxy Documentation, http://httpd.apache.org/docs/2.1/mod/mod_proxy.html

Page 9: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might a Proxy Server Be Useful?

Page 10: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Proxy Server with HTTP ServerIn Association

with:

•mod_cache

•mod_ssl

Standard Apache Distribution:

•mod_proxy

•mod_proxy_http

•mod_proxy_ftp

•mod_proxy_ajp

•mod_proxy_connect

Third Party:

•mod_proxy_html*

* Move to standard distribution as part of v2.4.0, http://bahumbug.wordpress.com/2011/10/28/modules-move-home/

Page 11: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Forward Proxy Server with HTTP

Server

ProxyRequests OnProxyVia On

Page 12: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Proxy Server with HTTP Server

<Proxy *>

Order Deny,Allow

Deny from all

Allow from 192.168.0

</Proxy>

Page 13: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Reverse Proxy Server with HTTP

Server

ProxyRequests Off

ProxyPass /back http://backend.example.com

ProxyPassReverse /back http://backend.example.com

ProxyHTMLURLMap http://backend.example.com /back

Page 14: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Load Balancers

Page 15: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Load Balancers

What is a Load Balancer?

When Might a Load Balancing be Useful?

How to Implement a Load Balancer with Apache HTTP Server

Page 16: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

What is a Load Balancer?

“A networking methodology to distribute workload across multiple resources.”3

3 From Wikipedia, http://en.wikipedia.org/wiki/Load_balancing_(computing)

Page 17: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might Load Balancing be Useful?

Page 18: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Proxy Server with HTTP ServerIn Association

with:

•mod_cache

•mod_ssl

Standard Apache Distribution:

•mod_proxy

•mod_proxy_http

•mod_proxy_ftp

•mod_proxy_ajp

•mod_proxy_connect

•mod_proxy_balancer

Third Party:

•mod_proxy_html*

* Move to standard distribution as part of v2.4.0, http://bahumbug.wordpress.com/2011/10/28/modules-move-home/

Page 19: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Failover Load Balancer with HTTP

ServerProxyRequests Off

ProxyPass /webapp balancer://cluster

ProxyPassReverse /webapp http://prime.example.com:80

ProxyPassReverse /webapp http://fail.example.com:80

ProxyHTMLURLMap http://prime.example.com:80 /webapp

ProxyHTMLURLMap http://fail.example.com:80 /webapp

<Proxy balancer://cluster>

BalancerMember http://prime.example.com:80

BalancerMember http://fail.example.com:80 status=+H

</Proxy>

Page 20: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might Load Balancing be Useful?

“Distribute workload across multiple computers or a computer cluster ... to achieve optimal resource utilization, maximize throughput, minimize response time, and avoid overload.”3

3 From Wikipedia, http://en.wikipedia.org/wiki/Load_balancing_(computing)

Page 21: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

When Might Load Balancing be Useful?

Page 22: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Load Balancer with HTTP Server

ProxyRequests Off

ProxyPass /webapp balancer://cluster \

stickysession=SESSIONID nofailover=On

Page 23: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Load Balancer with HTTP Server<Location /webapp>

ProxyPassReverse /webapp http://app1.example.com:80

ProxyPassReverse /webapp http://app2.example.com:80

ProxyPassReverse /webapp http://app3.example.com:80

ProxyHTMLURLMap http://app1.example.com:80 /webapp

ProxyHTMLURLMap http://app2.example.com:80 /webapp

ProxyHTMLURLMap http://app3.example.com:80 /webapp

ProxyPassReverseCookiePath /webapp/ /webapp

RequestHeader unset Accept-Encoding

</Location>

Page 24: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Load Balancer with HTTP Server

<Proxy balancer://cluster>

BalancerMember http://app1.example.com:80 loadfactor=50 route=app1

BalancerMember http://app2.example.com:80 loadfactor=25 route=app2

BalancerMember http://app3.example.com:80 loadfactor=25 route=app3

</Proxy>

Page 25: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Implementing a Load Balancer with HTTP Server

ProxyRequests Off

ProxyPass /webapp balancer://cluster stickysession=JSESSIONID nofailover=On

<Location /webapp>

ProxyPassReverse /webapp http://app1.example.com:80

ProxyPassReverse /webapp http://app2.example.com:80

ProxyPassReverse /webapp http://app3.example.com:80

ProxyHTMLURLMap http://app1.example.com:80 /webapp

ProxyHTMLURLMap http://app2.example.com:80 /webapp

ProxyHTMLURLMap http://app3.example.com:80 /webapp

ProxyPassReverseCookiePath /webapp/ /webapp

RequestHeader unset Accept-Encoding

</Location>

<Proxy balancer://cluster>

BalancerMember http://app1.example.com:80 loadfactor=50 route=app1

BalancerMember http://app2.example.com:80 loadfactor=25 route=app2

BalancerMember http://app3.example.com:80 loadfactor=25 route=app3

</Proxy>

Page 26: The Power of mod_proxy Proxy servers, load balancers and how to implement with Apache HTTP Server

Resources/Questions

• http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

• http://www.apachetutor.org/admin/reverseproxies

• http://apache.webthing.com/mod_proxy_html/

• http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html

• http://pdw.weinstein.org

• @pdweinstein