The mod_proxy Cookbook



Similar documents
Apache HTTP Server. Load-Balancing with Apache HTTPD 2.2 and later. Erik Abele

Apache httpd v2.4: Reverse Proxy. (The Hidden Gem) Jim Jagielski

Apache 2.2 and mod_proxy_balancer

Painless Web Proxying with Apache mod_proxy

EQUELLA. Clustering Configuration Guide. Version 6.2

Apache Tomcat. Load-balancing and Clustering. Mark Thomas, 20 November Pivotal Software, Inc. All rights reserved.

DEPLOYMENT GUIDE Version 1.0. Deploying the BIG-IP LTM with Apache Tomcat and Apache HTTP Server

1. Introduction 2. Getting Started 3. Scenario 1 - Non-Replicated Cluster 4. Scenario 2 - Replicated Cluster 5. Conclusion

What's new in httpd 2.2?

Cookbook Secure Failover for Tomcat Application Server Use Apache, mod_proxy, mod_security, mod_ssl to offer secure application delivery

White Paper DEPLOYING WDK APPLICATIONS ON WEBLOGIC AND APACHE WEBSERVER CLUSTER CONFIGURED FOR HIGH AVAILABILITY AND LOAD BALANCE

Scalability of web applications. CSCI 470: Web Science Keith Vertanen

Apache Tomcat & Reverse Proxies

What s new in Apache HTTP Server 2.2. Jim Jagielski jim@jagunet.com

High Availability Low Dollar Load Balancing

Apache Performance Tuning

Technical specification

By PANKAJ SHARMA. Concepts of Server Load Balancing

Setting Up B2B Data Exchange for High Availability in an Active/Active Configuration

Intro to Load-Balancing Tomcat with httpd and mod_jk

Configuring Remote HANA System Connection for SAP Cloud for Analytics via Apache HTTP Server as Reverse Proxy

Rails Application Deployment. July Philly on Rails

EQUELLA. Clustering Configuration Guide. Version 6.0

The course will be run on a Linux platform, but it is suitable for all UNIX based deployments.

Apache web server magic on IBM i. Alan Seiden Consulting alanseiden.com

Oracle9i Application Server: Options for Running Active Server Pages. An Oracle White Paper July 2001

PROXY SETUP WITH IIS USING URL REWRITE, APPLICATION REQUEST ROUTING AND WEB FARM FRAMEWORK OR APACHE HTTP SERVER FOR EMC DOCUMENTUM EROOM

Agenda. Tomcat Versions Troubleshooting management Tomcat Connectors HTTP Protocal and Performance Log Tuning JVM Tuning Load balancing Tomcat

Content. Global Delivery Network: Folders

DEPLOYMENT GUIDE Version 1.1. Deploying F5 with Oracle Application Server 10g

ID205 IBM Lotus inotes High Availability Customer Case Study and Successful Web Deployment Best Practices

An Esri White Paper January 2010 Performance and Throughput Tips for ArcGIS Server Cached Map Services and the Apache HTTP Server

Accelerating Rails with

Configuring Apache HTTP Server With Pramati

20 Things You Didn t Know You Could Do With Apache (aka httpd power tools) Rich Bowen rbowen@apache.org ApacheCon US 2006

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

Implementation of Web Application Firewall

How-to-Guide: Reverse Proxy and Load Balancing for SAP Mobile Platform 3.X

DEPLOYMENT GUIDE Version 1.1. Deploying the BIG-IP LTM v10 with Citrix Presentation Server 4.5

Building a Web Security Gateway </bhtalk>

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

ZEN LOAD BALANCER EE v3.04 DATASHEET The Load Balancing made easy

N Things You Didn t Know You Could Do With Apache

ZEN LOAD BALANCER EE v3.02 DATASHEET The Load Balancing made easy

Nginx 1 Web Server Implementation

FortiOS Handbook - Load Balancing VERSION 5.2.2

Deployment Guide Microsoft IIS 7.0

Load Balancing. FortiOS Handbook v3 for FortiOS 4.0 MR3

CLUSTERING CAS for High Availability. Eric Pierce, University of South Florida

DEPLOYMENT GUIDE Version 1.2. Deploying the BIG-IP System v10 with Microsoft IIS 7.0 and 7.5

Snapt Balancer Manual

How to setup HTTP & HTTPS Load balancer for Mediator

Oracle Collaboration Suite

Managing Virtual Servers

HAProxy. Free, Fast High Availability and Load Balancing. Adam Thornton 10 September 2014

Speed up your web site. Alan Seiden Consulting alanseiden.com

Implementing a Weblogic Architecture with High Availability

INTRODUCTION AND TERMINOLOGY

TFE listener architecture. Matt Klein, Staff Software Engineer Twitter Front End

Introduction to ServerIron ADX Application Switching and Load Balancing. Module 6: Content Switching (CSW) Revision 0310

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Deploying F5 for Microsoft Office Web Apps Server 2013

mod_cluster Documentation

Release Notes Date: September 2013

FortiOS Handbook Load Balancing for FortiOS 5.0

SiteCelerate white paper

High Availability HTTP/S. R.P. (Adi) Aditya Senior Network Architect

DEPLOYMENT GUIDE Version 1.0. Deploying the BIG-IP LTM with Apache Tomcat and Apache HTTP Server

Basic & Advanced Administration for Citrix NetScaler 9.2

DEPLOYMENT GUIDE Version 1.2. Deploying the BIG-IP System v9.x with Microsoft IIS 7.0 and 7.5

Deploying the BIG-IP System v10 with Oracle Application Server 10g R2

CS 188/219. Scalable Internet Services Andrew Mutz October 8, 2015

Configuring Nex-Gen Web Load Balancer

CS514: Intermediate Course in Computer Systems

CS640: Introduction to Computer Networks. Applications FTP: The File Transfer Protocol

1. When will an IP process drop a datagram? 2. When will an IP process fragment a datagram? 3. When will a TCP process drop a segment?

CentraSite SSO with Trusted Reverse Proxy

DEPLOYMENT GUIDE CONFIGURING THE BIG-IP LTM SYSTEM WITH FIREPASS CONTROLLERS FOR LOAD BALANCING AND SSL OFFLOAD

Robert Honeyman Honeyman IT Consulting.

ELIXIR LOAD BALANCER 2

Cisco AnyConnect Secure Mobility Solution Guide

Pass Through Proxy. How-to. Overview:..1 Why PTP?...1

HP ALM. Software Version: External Authentication Configuration Guide

Single Pass Load Balancing with Session Persistence in IPv6 Network. C. J. (Charlie) Liu Network Operations Charter Communications

TESTING & INTEGRATION GROUP SOLUTION GUIDE

Integrating the F5 BigIP with Blackboard

DEPLOYMENT GUIDE Version 2.1. Deploying F5 with Microsoft SharePoint 2010

Flexible Routing and Load Control on Back-End Servers. Controlling the Request Load and Quality of Service

DEPLOYMENT GUIDE Version 1.2. Deploying the BIG-IP system v10 with Microsoft Exchange Outlook Web Access 2007

Setup Guide Access Manager 3.2 SP3

DEPLOYMENT GUIDE. Deploying F5 for High Availability and Scalability of Microsoft Dynamics 4.0

<Insert Picture Here> Oracle Web Cache 11g Overview

DEPLOYMENT GUIDE DEPLOYING THE BIG-IP SYSTEM WITH MICROSOFT INTERNET INFORMATION SERVICES (IIS) 7.0

Implementing Reverse Proxy Using Squid. Prepared By Visolve Squid Team

Apache Performance Tuning Part Two: Scaling Out

Microsoft SharePoint 2013 with Citrix NetScaler

DEPLOYMENT GUIDE Version 1.1. Deploying F5 with IBM WebSphere 7

Transcription:

The mod_proxy Cookbook A collection of proxy recipes to suit your discerning palate Daniel Ruggeri

Who is This Guy? About Daniel Ruggeri Infrastructure guy with a love for code DRuggeri <at> apache.org Standard Disclaimer I'm speaking personally and not on behalf of my employer. The examples and comments are my personal opinions and should not be considered the official practices or positions of MasterCard.

Between You and Lunch About this presentation Not just mod_proxy Know thine application Warning eye charts ahead! Examples may be hard to read Included for completeness Download this presentation! http://people.apache.org/~druggeri/presentations/proxycookbook.odp

What's New and Hot? Embers - Ed Suominen - CC BY-NC 2.0 - https://www.flickr.com/photos/edsuom/

Newness - websockets WebSocket (RFC6455) support Full duplex socket Upgraded connection via HTTP/1.1 LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so ProxyPass /ws2/ ws://echo.websocket.org/

Newness - UDS Unix Domain Socket Local connection only A socket without all that TCP stuff Pipe separator ProxyPass / unix:/var/run/superapp.sock http://localhost/

Newness - mod_proxy_express Express Mass name-based, switch-like proxying Target server selection is driven by DBM file DBM file: www.homeawayfromhome.com http://10.0.1.25 login.homeawayfromhome.com http://10.0.2.15 Config file: ProxyExpressEnable on ProxyExpressDBMFile /path/to/mapfile

One done - Daniel Kulinski - CC BY-NC-SA 2.0 - https://www.flickr.com/photos/didmyself/6530389351

How to Be a Good Proxy Connection Marshaling/Protocol Enforcement Load Balancing/Session Stickiness Connection Pooling/TCP and SSL Offload Failover/Health Monitoring Dynamic Modification Traffic shaping/caching/compression Attack Mitigation (Security)

Connection Marshaling/Protocol Enforcement Dalian Traffic Cops 06 - SnoShuu - CC BY-NC-ND 2.0 - https://www.flickr.com/photos/snoshuu/

Playing Traffic Cop Separates clients and servers The difference between forward and reverse proxy What does the client know? Forward proxy mod_proxy_connect for SSL Reverse proxy uses mod_proxy_(ajp http ftp scgi fcgi wstunnel) mod_ssl and SSLProxyEngine for SSL

Forward Proxy Example WARNING: Do not proceed until you know how to lock this down! LoadModule proxy_connect_module modules/mod_proxy_connect.so <VirtualHost 10.1.2.3:8888> ProxyRequests On <Proxy *> Require ip 192.168 </Proxy> </VirtualHost>

Reverse Proxy Examples In a Location block <Location /application> ProxyPass http://backend.local/application </Location> Standalone ProxyPass directive ProxyPass /application http://backend.local/application ProxyPassReverse /application http://backend.local/application

Reverse Proxy Examples As a ProxyPassMatch ProxyPassMatch /application/.*.do http://backend.local/application/ In the Rewrite engine RewriteCond %{HTTP_COOKIE} TOP_SECRET_ACCESS RewriteRule ^/admin/(.*) http://backend.local/admin/ [P]

Reverse Proxy Examples As a Balancer <Proxy balancer://mycluster> Balancer BalancerMember http://1.2.3.4:8009 route=mercury BalancerMember http://1.2.3.5:8009 route=venus ProxySet lbmethod=byrequests nonce=none stickysession=jsessionid </Proxy> Workers ProxyPass /myapp/ balancer://mycluster/myapp/

Reverse Proxy Examples As a DB (2.4) ProxyExpressEnable on ProxyExpressDBMFile /path/to/mapfile As a Handler (2.4.10+) <FilesMatch \.php$> # Unix sockets require 2.4.7 or later SetHandler "proxy:unix:/path/to/app.sock fcgi://localhost/" </FilesMatch>

Load Balancing/Traffic Distribution network - Martin Abegglen - CC BY-SA 2.0 - https://www.flickr.com/photos/twicepix/4333178624

Load Distribution byrequests Perform balancing based solely on requests served bytraffic Perform balancing by byte count (in response body) served bybusyness Perform balancing based on how many pending requests exist for a backend heartbeat??? Perform balancing based on What mod_heartbeat tells us Some rumblings of what is coming

Load Distribution Asymmetric distribution loadfactor option for BalancerMember higher number == higher load +H option for hot-standby Disables worker until others are unavailable Don t forget lbset as another option Selective proxying using! and ordering Do not proxy certain paths

Example: Weighting <Proxy balancer://mycluster> BalancerMember http://1.2.3.4:8009 loadfactor=2 BalancerMember http://1.2.3.5:8009 smax=10 loadfactor=2 #Less powerful server fewer requests BalancerMember http://1.2.3.6:8009 smax=1 loadfactor=1 </Proxy> ProxyPass / balancer://mycluster/ stickysession=jsessionid

Example: Hot Standby <Proxy balancer://hotcluster> BalancerMember http://1.2.3.4:8009 BalancerMember http://1.2.3.5:8009 #Hot standby BalancerMember http://1.2.3.6:8009 status=+h ProxySet lbmethod=bytraffic </Proxy> ProxyPass / balancer://hotcluster/

Example: Selective Proxying <Proxy balancer://appcluster1> BalancerMember http://1.2.3.4:8009 BalancerMember http://1.2.3.5:8009 </Proxy> <Proxy balancer://appcluster2> BalancerMember http://9.8.7.6:8080 BalancerMember http://9.8.7.5:8080 </Proxy> ProxyPass /static/! ProxyPass /applicationa/ balancer://appcluster1/ ProxyPass /applicationb/ balancer://appcluster2/ ProxyPass / balancer://hotcluster/

Worker Statuses Disabled (D) Worker is disabled and will not accept any requests. Stopped (S) Worker is administratively stopped. Ignore Errors (I) Will always be considered available. Hot Standby (H) Will only be used if no other viable workers are available. Error (E) Will not be used due to error. Drain (N) Will only accept existing sticky sessions for its route. Redirect* New requests without sessions will go here.

Sticky Sessions Gecko-017 - VinceFL - CC BY-NC-ND 2.0 - https://www.flickr.com/photos/vlopresti1964/9780815161

Session Persistence Session replication can be expensive Built-in (as designed) mod_proxy_balancer includes facilities to do this Not always compatible or easy Roll your own Use the built-in functions but tweak to your liking Route parameter comes into play

A Sticky Matter Many different formats for session identifiers based on backend. Cookies, URLs, formats, etc You have to know a lot Name of the cookie Values contained Built-in is not 100% compatible. (2.2) Requires dot or semicolon as a delimiter (2.4) stickysessionsep can be anything

Universal Sticky!!! LoadModule headers_module modules/mod_headers.so <Proxy balancer://danielcluster> BalancerMember http://1.2.3.4:8009 route=mercury BalancerMember http://1.2.3.5:8009 route=venus ProxySet stickysession=danielsapp_sticky </Proxy> Header add Set-Cookie "DanielsApp_STICKY=sticky.%{BALANCER_WORKER_ROUTE}e;path=/;" env=balancer_route_changed ProxyPass /daniel/ balancer://danielcluster/daniel/

Connection Pooling/TCP and SSL Offload Quiet Cove pool at night - Ricky Brigante - CC BY-NC-ND 2.0 - https://www.flickr.com/photos/insidethemagic/7021197905

Get in the Pool So easy it is almost automatic Parameters max hard maximum smax soft maximum (aggressive TTL cleanup) ttl time allowed to be idle Other parameters come into play Complications... TCP/HTTP Keepalive

Example: Connection Pooling <Proxy balancer://mycluster> BalancerMember http://1.2.3.4:8009 smax=7 max=10 ttl=10 BalancerMember http://1.2.3.5:8009 smax=7 max=10 ttl=10 </Proxy> ProxyPass / balancer://mycluster/

Leave the Tough Stuff to Me Funnel all traffic into the pipeline Many requests <-> one backend connection keepalive is a beautiful thing SSL benefits as well HTTPS to HTTPD Can run HTTP or HTTPS to backend Either will be more efficient! Node.js use case

Failover/Health Monitoring Doctor Visit - Laura Smith - CC BY-NC-ND 2.0 - https://www.flickr.com/photos/blushingmulberry/4182291013

Failure Detection Failover capability for connection only Connection errors fail over to next backend seamlessly. SSL errors go back to user.... and are taken out of service as of 2.2.18. Hung/slow backend errors go back to user.... but can be taken out of service as of 2.2.25/2.4.5 with failontimeout.

I Don't Feel So Well No heath check capability Requires real, live traffic Must come up with a way to work around it In the future... Scratch your own itch, Daniel!

Mitigating Controls connectiontimeout Sets the number of seconds to wait for a TCP connection. ProxyTimeout and failontimeout Fail faster and mark the backend out of service Warning - this may be bad for you Failonstatus Mark a backend out of service if a specific HTTP status code is found Monitoring Create external monitoring to force traffic through HTTPD.

Dynamic Modification The Pleasant Glow of Good Music - Bob Prosser - CC BY-NC-ND 2.0 - https://www.flickr.com/photos/b-love/9723724344

Doing the Shuffle BalancerManager is how one modifies members. Good selection of parameters Balancer sticky identifier, timeout, failover, failover attempts, lbmethod Workers can be added if growth is set Workers can not be removed Worker loadfactor, lbset, route, redirect ignore errors, draining, disabled, hot standby Be safe out there

Lay Thine Eyes Upon It!

Balancer Manager Errata Nonce usage Set the nonce or use "None" for scripting XML output Useful for machines REST-like (todo) b, w and nonce parameters part of URL Persistance over restart (2.4.4) Will write state before shutdown Be careful out there

Shaping Pottery - o.lila - CC BY-NC-SA 2.0 - https://www.flickr.com/photos/o_lila/7905806898

Traffic Tweaking Caching via mod_cache Too much to cover here. Compress via mod_deflate Shape via... mod_proxy_html, mod_headers, mod_rewrite, mod_substitute, mod_sed mod_env/mod_setenvif, mod_expires, mod_*filter Watch with mod_dumpio The sky is the limit!

Example: Traffic Shaping ProxyPass /app balancer://mycluster/appl ProxyPassReverse /app balancer://mycluster/app <Location /app> AddOutputFilterByType SUBSTITUTE text/html Substitute "s http://127.0.0.1:7004 http://mypage n" RequestHeader set environment production AddOutputFilterByType DEFLATE text/html text/xml </Location>

Security Learning the hard way - Ludovic Bertron -CC BY 2.0 - https://www.flickr.com/photos/23912576@n05/ -

Not in MY House... Security modules mod_noloris, mod_security, etc Separation Tiered approach Standards enforcement Filtering/Blocking/Restricting Allow from certain hosts Authn/Authz modules The sky is (still) the limit!

Questions? Scenarios? Feedback: druggeri <at> apache.org Download me: http://people.apache.org/~druggeri/presentations/proxycookbook.odp