Gestione della configurazione di Apache con il modulo puppetlabs-apache
Jump to navigation
Jump to search
Ecco un esempio di un virtualhost apache che fa da reverse proxy
class miovserver {
class { 'apache': }
class { 'apache::mod::ssl': }
class { 'apache::mod::proxy': }
class { 'apache::mod::proxy_http': }
apache::namevirtualhost {"*:80":}
apache::vhost { "miovserver.example.priv":
vhost_name => '*',
port => '80',
servername => "miovserver.example.priv",
serveraliases => ['miovserver',
],
#server_signature => "On",
docroot => "/var/www",
ssl_proxyengine => true,
proxy_pass => [
{ 'path' => '/',
'url' => 'https://altroserver.example.priv/',
'params' => {
'retry' => 1,
'acquire' => 3000,
'timeout' => 600,
'Keepalive' => 'On',
},
},
],
custom_fragment => "
SSLPRoxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1",
}
}
Questa configurazione, oltre che ad impostare i parametri generici di apache2, produce un file di configurazione del virtualhost come segue:
cat /etc/apache2/sites-enabled/25-mioserver.example.priv.conf
# ************************************
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************
<VirtualHost *:80>
ServerName mioserver.example.priv
## Vhost docroot
DocumentRoot "/var/www"
## Directories, there should at least be a declaration for /var/www
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
## Logging
ErrorLog "/var/log/apache2/mioserver.example.priv_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/mioserver.example.priv_access.log" combined
## Proxy rules
ProxyRequests Off
ProxyPass / https://altroserver..example.priv/ Keepalive=On acquire=3000 retry=1 timeout=600
<Location />
ProxyPassReverse https://altroserver..example.priv/
</Location>
## Server aliases
ServerAlias mioserver
## Custom fragment
SSLPRoxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
Timeout 2400
ProxyTimeout 2400
ProxyBadHeader Ignore
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</VirtualHost>