1. Proxing to tomcat with httpd
Jean-Frederic Clere
Principal Software Engineer / Red Hat
2. What I will cover
●
Proxy what and why.
●
Protocols
– AJP
– HTTP/HTTPS (1.1)
– HTTP/2 (H2 and H2C)
– Others proxy and Other protocols (web-socket etc)
●
Configuration
– mod_jk, mod_proxy, http/1.1 basic, h2c, h2
– https /TLS proxying
●
Demo
●
QUESTIONS?
10/12/22
2
3. Who I am
Jean-Frederic Clere
Red Hat
Years writing JAVA code and server software
Tomcat committer since 2001
Doing OpenSource since 1999
Cyclist/Runner etc
Lived 15 years in Spain (Barcelona)
Now in Neuchâtel (CH)
10/12/22
3
4. What is Proxy?
●
Something between the application server and the internet.
●
Load-balancer
●
Failover
●
Protocol termination
– TLS/SSL
– HTTP/2 and (soon) HTTP/3
●
Understands a protocol and possible upgrades.
10/12/22
4
5. Why a proxy?
●
Control the load
●
Serve static pages
●
Control requests: mod_security / mod_rewrite etc
●
Dynamic configuration (mod_balancer/mod_cluster…)
●
Protocol translations
10/12/22
5
6. AJP
●
When
– Easy TLS/SSL forwarding
●
Limitations
– No upgrade
– Header size
– No encryption
– Limited “authentication” (secret)
●
mod_proxy_ajp and mod_jk
10/12/22
6
7. HTTP and HTTPS 1.1
●
When:
– No SSL forwarding
– Using SSLValve
●
HTTP/HTTPS:
– HTTPS might be needed (Encryption/Authentication)
– HTTPS on tomcat (openssl again?)
– HTTP if you trust your intranet. (really?)
●
Other reasons:
– HTTP is more developed than AJP
10/12/22
7
10. Conclusion AJP/HTTP
●
No big difference mod_proxy_ajp/mod_jk
●
AJP more easy (no Valve needed)
●
AJP not encrypted
●
AJP has no upgrade
10
10/12/22
11. H2C
●
h2c is only for reverse proxy
– <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
●
Supported by httpd
11
10/12/22
12. Demultiplexing h2 in proxy
● Keep the back-end unchanged
● Keep the overhead of h2 in the proxy
12
10/12/22
13. Other proxies
●
HAProxy (in the cloud / openshift for example)
●
mod_cluster (httpd dynamic load balancer)
●
Undertow proxy (jboss servlet container)
●
Ingress (in kubernetes, well Nginx or GCE)
●
Traffic Server
●
Nginx
10/12/22
13
15. So proxy or not proxy
●
Fail-over : yes
●
H2 and old HTTP/1.1 tomcat : yes? Really? Danger?
●
Pure java tomcat + TLS/SSL : yes
●
Otherwise: Not needed
10/12/22
15
16. mod_jk configuration
●
Httpd.conf
LoadModule jk_module modules/mod_jk.so
JkMount /jkaj/* worker1
JkWorkersFile conf/workers.properties
●
properties
# Define 1 real worker using ajp13
worker.list=worker1
worker.worker1.type=lb
worker.worker1.balance_workers=clusterdev03,clusterdev04
# Set properties for workers (ajp13)
worker.clusterdev03.type=ajp13
worker.clusterdev03.host=192.168.0.130
worker.clusterdev03.port=8009
worker.clusterdev04.type=ajp13
worker.clusterdev04.host=192.168.0.140
worker.clusterdev04.port=8009 16
10/12/22
24. Using TLS (2 httpd)
Httpd.conf add headers for Valve
# export the ssl variables
SSLOptions +StdEnvVars +ExportCertData
# Use mod_headers to add them as headers.
RequestHeader set SSL_CLIENT_CERT "%{SSL_CLIENT_CERT}s"
RequestHeader set SSL_CIPHER "%{SSL_CIPHER}s"
RequestHeader set SSL_SESSION_ID "%{SSL_SESSION_ID}s"
RequestHeader set SSL_CIPHER_USEKEYSIZE "%{SSL_CIPHER_USEKEYSIZE}s"
10/12/22
10/12/22
10/12/22
24
25. Demo
8007: just encrypt httpd-tomcat (makes no sense!!!).
8000: encrypt both. (makes sense)
8888: encrypt both. (makes sense) and get client certificates. (remember PEM vs pem)
9999: h2c proxy
9998: h2 proxy
See: https://github.com/jfclere/AC2022/blob/main/proxy/tomcat-proxy.conf
Remember: LogLevel proxy_module:debug (or ssl_module:debug) will help!
10/12/22
10/12/22
10/12/22
25