add init apache conf

This commit is contained in:
pettai 2024-06-13 12:31:51 +02:00
parent e2154852e4
commit 7215ddeb2b
No known key found for this signature in database
GPG key ID: CDF2C381E9A751BD
2 changed files with 41 additions and 8 deletions

View file

@ -7,15 +7,22 @@ class dns::apache2 {
ensure => running,
enable => true,
}
exec { 'a2enmod ssl && a2enmod headers && a2enmod proxy && a2enmod proxy_http && a2enmod request && a2enmod rewrite':
#subscribe => File['/etc/apache2/sites-available/default-ssl.conf'],
# Configuration of the web service follows.
file { '/etc/apache2/sites-available/dns-rest-api.conf':
ensure => file,
mode => '0644',
content => template('dns/apache2/dns-rest-api.conf.erb'),
notify => Service['apache2'],
}
exec { 'a2enmod ssl && a2enmod headers && a2enmod proxy && a2enmod proxy_http && a2enmod request && a2enmod rewrite && a2enmod allowmethods':
subscribe => File['/etc/apache2/sites-available/dns-rest-api.conf'],
refreshonly => true,
notify => Service['apache2'],
}
# exec { 'a2dissite default-ssl.conf':
# notify => Service['apache2'],
# }
# exec { 'a2dissite default-000.conf':
# notify => Service['apache2'],
# }
exec { 'a2dissite default-000.conf':
notify => Service['apache2'],
}
exec { 'a2ensite dns-rest-api.conf':
notify => Service['apache2'],
}
}

View file

@ -0,0 +1,26 @@
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =dns-rest-api.sunet.se
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Location "/">
AllowMethods GET POST PATCH PUT DELETE
</Location>
ProxyTimeout 59
RequestHeader unset X-Remote-User early
ProxyPass "/" "http://localhost:5000/" connectiontimeout=59 timeout=59 Keepalive=On
ProxyPreserveHost On
ServerName dns-rest-api.sunet.se
SSLCertificateFile /etc/letsencrypt/live/dns-rest-api.sunet.se/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dns-rest-api.sunet.se/privkey.pem
</VirtualHost>
</IfModule>