Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linux-setup suse httpd configuration #734

Merged
merged 1 commit into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions jans-linux-setup/setup_app/installers/httpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self):
self.httpdKeyFn = os.path.join(Config.certFolder, 'httpd.key')
self.httpdCertFn = os.path.join(Config.certFolder, 'httpd.crt')


self.templates_folder = os.path.join(Config.templateFolder, 'apache')
self.output_folder = os.path.join(Config.outputFolder, 'apache')

Expand All @@ -35,21 +36,29 @@ def __init__(self):
self.apache2_24_conf = os.path.join(self.output_folder, 'httpd_2.4.conf')
self.apache2_ssl_24_conf = os.path.join(self.output_folder, 'https_jans.conf')

self.server_root = '/var/www/html'

if base.os_type == 'suse':
self.https_jans_fn = '/etc/apache2/vhosts.d/_https_jans.conf'
self.server_root = '/srv/www/htdocs'
self.apache_user = 'wwwrun'
self.apache_group = 'wwwrun'
elif base.clone_type == 'rpm':
self.https_jans_fn = '/etc/httpd/conf.d/https_jans.conf'
self.apache_user = 'apache'
self.apache_group = 'apache'
else:
self.https_jans_fn = '/etc/apache2/sites-available/https_jans.conf'

self.apache_user = 'www-data'
self.apache_group = 'www-data'

def configure(self):
self.logIt(self.pbar_text, pbar=self.service_name)
self.stop()

self.write_httpd_config()

self.writeFile('/var/www/html/index.html', 'OK')
self.writeFile(os.path.join(self.server_root, 'index.html'), 'OK')

if base.snap:
icons_conf_fn = '/etc/apache2/mods-available/alias.conf'
Expand All @@ -72,10 +81,10 @@ def configure(self):
error_templates = glob.glob(os.path.join(self.templates_folder,'error_pages/*.html'))

for tmp_fn in error_templates:
self.copyFile(tmp_fn, '/var/www/html')
self.copyFile(tmp_fn, self.server_root)

# we only need these modules
mods_enabled = ['env', 'log_config', 'proxy', 'proxy_http', 'access_compat', 'alias', 'authn_core', 'authz_core', 'authz_host', 'headers', 'mime', 'mpm_event', 'proxy_ajp', 'security2', 'reqtimeout', 'setenvif', 'socache_shmcb', 'ssl', 'unique_id', 'rewrite']
mods_enabled = ['env', 'log_config', 'proxy', 'proxy_http', 'access_compat', 'alias', 'authn_core', 'authz_core', 'authz_host', 'headers', 'mime', 'mpm_event', 'proxy_ajp', 'security2', 'reqtimeout', 'setenvif', 'socache_shmcb', 'ssl', 'unique_id', 'rewrite', 'mod_dir']

cmd_a2enmod = shutil.which('a2enmod')
cmd_a2dismod = shutil.which('a2dismod')
Expand Down Expand Up @@ -123,16 +132,6 @@ def configure(self):
cmd_a2enflag = shutil.which('a2enflag')
self.run([cmd_a2enflag, 'SSL'])

httpd_conf_fn = '/etc/apache2/httpd.conf'
httpd_conf_txt = self.readFile(httpd_conf_fn)
httpd_conf = httpd_conf_txt.splitlines()

for i, l in enumerate(httpd_conf[:]):
if l.strip().startswith('DirectoryIndex'):
httpd_conf[i] = l.replace('DirectoryIndex', '#DirectoryIndex')

self.writeFile(httpd_conf_fn, '\n'.join(httpd_conf))

else:
modules_config_dir = '/etc/apache2/sysconfig.d' if base.os_type == 'suse' else '/etc/httpd/conf.modules.d'
for mod_load_fn in glob.glob(os.path.join(modules_config_dir,'*')):
Expand Down
6 changes: 3 additions & 3 deletions jans-linux-setup/templates/apache/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15

Alias /error/ "/var/www/error/"
Alias /icons/ "/var/www/icons/"
Alias /error/ "%(server_root)s/error/"
Alias /icons/ "%(server_root)s/icons/"

UseCanonicalName On
TypesConfig /etc/mime.types
Expand Down Expand Up @@ -72,7 +72,7 @@ LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access_log combined

<Directory "/var/www/icons">
<Directory "%(server_root)s/icons">
Options -Indexes MultiViews
AllowOverride None
Order allow,deny
Expand Down
4 changes: 2 additions & 2 deletions jans-linux-setup/templates/apache/https_jans.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<VirtualHost *:80>
ServerName %(hostname)s
Redirect / https://%(hostname)s/
DocumentRoot "/var/www/html/"
DocumentRoot "%(server_root)s"
</VirtualHost>

<VirtualHost *:443>
DocumentRoot "/var/www/html/"
DocumentRoot "%(server_root)s"
ServerName %(hostname)s:443

LogLevel warn
Expand Down