Mass Virtual Hosting with Apache 2.0 Paul Querna - - PowerPoint PPT Presentation

mass virtual hosting with apache 2 0
SMART_READER_LITE
LIVE PREVIEW

Mass Virtual Hosting with Apache 2.0 Paul Querna - - PowerPoint PPT Presentation

Mass Virtual Hosting with Apache 2.0 Paul Querna chip@OutOfOrder.cc Virtual Hosts IP Address Required for HTTPS The 'Host' Header Mass Virtual Hosting? HTTPD's Default configuration doesn't deal well with thousands of


slide-1
SLIDE 1

Mass Virtual Hosting with Apache 2.0

Paul Querna

chip@OutOfOrder.cc

slide-2
SLIDE 2

Virtual Hosts

  • IP Address

– Required for HTTPS

  • The 'Host' Header
  • Mass Virtual Hosting?

– HTTPD's Default configuration doesn't deal well

with thousands of Virtual Hosts!

slide-3
SLIDE 3

Considerations

  • Security

– Suexec? – PHP? – Perchild? – Root?

  • Performance

– Hits/Second – Memory

  • Maintainable

– You have to Administrate it!

slide-4
SLIDE 4

Logging

  • Standard log files?

– Multiple Server? – Thousands of Virtual Hosts? – 'Split Later'

  • Piped Logging
  • mod_log_spread
slide-5
SLIDE 5

Static Vhosts

  • httpd.conf
  • Include vhosts.d/*.conf

– foo.bar.com.conf

slide-6
SLIDE 6

Advantages

  • Speed

– No special lookup methods

  • Configuration

– Every Directive is available

slide-7
SLIDE 7

Problems

  • Scripting?

– mod_macro lessens the complexity

  • Requires Graceful Restarts

– Add A Vhost – Change a Vhost

  • Wasted Memory

– Many sites are rarely

  • Multiple Servers?
  • Root?

– How can you edit or script the configuration

files?

– Restarting Apache?

slide-8
SLIDE 8

mod_rewrite

  • Using a RewriteMap:

RewriteMap lowercase int:tolower RewriteMap vhost txt:/etc/httpd/conf/vhost.map RewriteCond %{HTTP_HOST} !^$ RewriteCond ${lowercase:%{HTTP_HOST}|NONE} ^(.+)$ RewriteCond ${vhost:%1} ^(/.*)$ RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]

slide-9
SLIDE 9

Advantages

  • Speed

– Fast Lookups -- To a Point!

  • Easy to add a Virtual Host
slide-10
SLIDE 10

Problems

  • Security?

– PHP? – Suexec?

  • Multiple Servers?
  • Root?

– Edit RewriteMap File

slide-11
SLIDE 11

mod_vhost_alias

  • Uses the host header to determinate the

filename: VirtualDocumentRoot /vhosts/%0

  • Use Symlinks for ServerAliases?
slide-12
SLIDE 12

Advantages

  • Easy to Setup
  • Fast!

– No external lookups

  • Based on file system layout

– Can be shared across servers.

slide-13
SLIDE 13

Problems

  • Security?

– Suexec – Can work – PHP

  • Root?

– Changing a file system?

slide-14
SLIDE 14

mod_vhost_dbi

  • Uses a LibDBI database to provide

information about a Vhost.

mod_vhost_dbi mod_dbi_pool libdbi MySQL Postgres Oracle SQLlite

slide-15
SLIDE 15

mod_dbi_pool

PoolDbiDriver Server1 mysql PoolDbiHost Server1 10.0.0.20 PoolDbiUsername Server1 myuser PoolDbiPassword Server1 mypass PoolDbiDBName Server1 vhost_dbi PoolDbiConnMin Server1 1 PoolDbiConnSoftMax Server1 1 PoolDbiConnHardMax Server1 5 PoolDbiConnTTL Server1 30

slide-16
SLIDE 16

mod_vhost_dbi

<VirtualHost *:80> VhostDbiEnabled On VhostDbiConnName Server1 VhostDbiQuery “SELECT ServerName, DocumentRoot, UserName FROM VhostInfo WHERE ServerName = ''&{RequestHostname}” </VirtualHost>

slide-17
SLIDE 17

Advantages

  • Security

– Suexec – PHP OpenBaseDir

  • Not Perfect!
  • Root?

– No Need

  • No Configuration Files to Change
  • No Server to Restart
slide-18
SLIDE 18

Problems

  • Depends on a Database Server

– Performance Implications – Uptime?

slide-19
SLIDE 19

Resources

  • Slides, mod_vhost_dbi:

– http://www.outoforder.cc/

  • Virtual Hosts:

– The Apache Documentation!

  • http://httpd.apache.org/docs-2.0/vhosts/
slide-20
SLIDE 20

Questions?