Skip to content

Commit 73748c6

Browse files
committed
Manually merge PR192 to add support for easy built-in status page virtual hosting.
git-svn-id: svn+ssh://svn.code.sf.net/p/migrid/code/trunk@6208 b75ad72c-e7d7-11dd-a971-7dbc132099af
1 parent 6d2b046 commit 73748c6

File tree

8 files changed

+100
-11
lines changed

8 files changed

+100
-11
lines changed

mig/install/apache-MiG-template.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ Alias /assets/ "__MIG_CODE__/assets/"
114114
Alias /public/ "__MIG_STATE__/wwwpublic/"
115115
# Bind security.txt (https://securitytxt.org/) once and for all
116116
Alias /.well-known/security.txt "__MIG_STATE__/wwwpublic/.well-known/security.txt"
117+
<IfDefine STATUS_ALIAS_FQDN>
118+
# Status page helpers
119+
Alias /status.html "__MIG_STATE__/wwwpublic/status.html"
120+
Alias /status-events.json "__MIG_STATE__/wwwpublic/status-events.json"
121+
</IfDefine>
117122
<Directory "__MIG_STATE__/wwwpublic">
118123
AuthType none
119124
<IfVersion > 2.2>
@@ -432,6 +437,9 @@ __IS_VERIFYCERTS_COMMENTED__ <VirtualHost *:${PUBLIC_HTTP_PORT}>
432437
<IfDefine PUBLIC_ALIAS_FQDN>
433438
ServerAlias ${PUBLIC_ALIAS_FQDN}
434439
</IfDefine>
440+
<IfDefine STATUS_ALIAS_FQDN>
441+
ServerAlias ${STATUS_ALIAS_FQDN}
442+
</IfDefine>
435443
# Optionally add extra server aliases for current and future use here
436444
#ServerAlias something.__BASE_FQDN__ somethingelse.__BASE_FQDN__
437445

@@ -475,6 +483,11 @@ __IS_VERIFYCERTS_COMMENTED__ <VirtualHost *:${PUBLIC_HTTP_PORT}>
475483
__PREFER_HTTPS_COMMENTED__ RewriteCond %{HTTP_HOST} ^${PUBLIC_ALIAS_FQDN}$
476484
__PREFER_HTTPS_COMMENTED__ RewriteRule ^/?(.*) https://${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}/$1 [R,L]
477485
__PREFER_HTTPS_COMMENTED__ </IfDefine>
486+
__PREFER_HTTPS_COMMENTED__ <IfDefine STATUS_ALIAS_FQDN>
487+
__PREFER_HTTPS_COMMENTED__ RewriteCond %{HTTPS} off
488+
__PREFER_HTTPS_COMMENTED__ RewriteCond %{HTTP_HOST} ^${STATUS_ALIAS_FQDN}$
489+
__PREFER_HTTPS_COMMENTED__ RewriteRule ^/?(.*) https://${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}/$1 [R,L]
490+
__PREFER_HTTPS_COMMENTED__ </IfDefine>
478491
__PREFER_HTTPS_COMMENTED__</IfDefine>
479492

480493
# NOTE: redirect all remaining enabled protected address requests to https
@@ -609,6 +622,9 @@ __IS_VERIFYCERTS_COMMENTED__ <VirtualHost *:${PUBLIC_HTTP_PORT}>
609622
<VirtualHost ${PUBLIC_FQDN}:${PUBLIC_HTTPS_PORT}>
610623
ServerName ${PUBLIC_FQDN}
611624
ServerAlias __BASE_FQDN__
625+
<IfDefine STATUS_ALIAS_FQDN>
626+
ServerAlias ${STATUS_ALIAS_FQDN}
627+
</IfDefine>
612628
# Optionally add extra server aliases for current and future use here
613629
#ServerAlias something.__BASE_FQDN__ somethingelse.__BASE_FQDN__
614630

@@ -660,6 +676,12 @@ __IS_VERIFYCERTS_COMMENTED__ <VirtualHost *:${PUBLIC_HTTP_PORT}>
660676
RewriteLogLevel 0
661677
</IfVersion>
662678

679+
<IfDefine STATUS_ALIAS_FQDN>
680+
# Redirect implict target to status page
681+
RewriteCond %{SERVER_NAME} ^${STATUS_ALIAS_FQDN}$
682+
RewriteRule ^(/*)$ /status.html [L,R]
683+
</IfDefine>
684+
663685
# Break rewriting chain for commonly-requested final destinations
664686
# * Direct files (including subrequest for /X.py from /wsgi-bin/X.py)
665687
# * Xgi scripts
@@ -734,6 +756,9 @@ __IS_VERIFYCERTS_COMMENTED__ <VirtualHost *:${PUBLIC_HTTP_PORT}>
734756
<IfDefine PUBLIC_ALIAS_FQDN>
735757
<VirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}>
736758
ServerName ${PUBLIC_ALIAS_FQDN}
759+
<IfDefine STATUS_ALIAS_FQDN>
760+
ServerAlias ${STATUS_ALIAS_FQDN}
761+
</IfDefine>
737762
# General setup for the virtual host
738763
DocumentRoot "__MIG_STATE__/wwwpublic"
739764
ErrorLog __APACHE_LOG__/ssl-error.log
@@ -774,6 +799,12 @@ __IS_VERIFYCERTS_COMMENTED__ <VirtualHost *:${PUBLIC_HTTP_PORT}>
774799
RewriteLogLevel 0
775800
</IfVersion>
776801

802+
<IfDefine STATUS_ALIAS_FQDN>
803+
# Redirect implict target to status page
804+
RewriteCond %{SERVER_NAME} ^${STATUS_ALIAS_FQDN}$
805+
RewriteRule ^(/*)$ /status.html [L,R]
806+
</IfDefine>
807+
777808
# Break rewriting chain for commonly-requested final destinations
778809
# * Internal Aliased helper locations
779810
RewriteCond %{QUERY_STRING} ^$

mig/install/apache-apache2-template.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ IncludeOptional __APACHE_ETC__/production-mode*.conf
4848
# Always-on vhosts both for emergency and production mode
4949
__IFDEF_PUBLIC_FQDN__ PUBLIC_FQDN __PUBLIC_FQDN__
5050
__IFDEF_PUBLIC_ALIAS_FQDN__ PUBLIC_ALIAS_FQDN __PUBLIC_ALIAS_FQDN__
51+
__IFDEF_STATUS_ALIAS_FQDN__ STATUS_ALIAS_FQDN __STATUS_ALIAS_FQDN__
5152
# User vhosts are ONLY enabled in actual production mode
5253
<IfDefine PRODUCTION_MODE>
5354
__IFDEF_BASE_FQDN__ BASE_FQDN __BASE_FQDN__

mig/install/apache-ports-template.conf

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ Listen ${PUBLIC_HTTP_PORT}
3333
</IfDefine>
3434
<IfDefine PUBLIC_ALIAS_FQDN>
3535
<IfDefine PUBLIC_HTTPS_PORT>
36-
<IfDefine PRODUCTION_MODE>
37-
#NameVirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
36+
__APACHE_PRE2.4__ NameVirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
3837
__PUBLIC_ALIAS_HTTPS_LISTEN__ ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
3938
</IfDefine>
40-
<IfDefine !PRODUCTION_MODE>
41-
# Also force listen on PUBLIC_ALIAS_FQDN here if not in PRODUCTION_MODE
42-
Listen ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
4339
</IfDefine>
40+
<IfDefine STATUS_ALIAS_FQDN>
41+
<IfDefine PUBLIC_HTTPS_PORT>
42+
__APACHE_PRE2.4__ NameVirtualHost ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
43+
__STATUS_ALIAS_HTTPS_LISTEN__ ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
4444
</IfDefine>
4545
</IfDefine>
4646
<IfDefine MIG_CERT_FQDN>
@@ -66,10 +66,16 @@ Listen ${PUBLIC_HTTP_PORT}
6666
<IfModule mod_gnutls.c>
6767
<IfDefine PUBLIC_ALIAS_FQDN>
6868
<IfDefine PUBLIC_HTTPS_PORT>
69-
#NameVirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
69+
__APACHE_PRE2.4__ NameVirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
7070
__PUBLIC_ALIAS_HTTPS_LISTEN__ ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
7171
</IfDefine>
7272
</IfDefine>
73+
<IfDefine STATUS_ALIAS_FQDN>
74+
<IfDefine PUBLIC_HTTPS_PORT>
75+
__APACHE_PRE2.4__ NameVirtualHost ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
76+
__STATUS_ALIAS_HTTPS_LISTEN__ ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
77+
</IfDefine>
78+
</IfDefine>
7379
<IfDefine MIG_CERT_FQDN>
7480
<IfDefine MIG_CERT_PORT>
7581
__APACHE_PRE2.4__ NameVirtualHost ${MIG_CERT_FQDN}:${MIG_CERT_PORT}

mig/install/generateconfs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# --- BEGIN_HEADER ---
55
#
66
# generateconfs - create custom MiG server configuration files
7-
# Copyright (C) 2003-2025 The MiG Project
7+
# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH
88
#
99
# This file is part of MiG.
1010
#
@@ -77,6 +77,7 @@ def main(argv, _generate_confs=generate_confs, _print=print):
7777
'base_fqdn',
7878
'public_fqdn',
7979
'public_alias_fqdn',
80+
'status_alias_fqdn',
8081
'public_sec_fqdn',
8182
'mig_cert_fqdn',
8283
'ext_cert_fqdn',

mig/shared/install.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def generate_confs(
296296
base_fqdn='',
297297
public_fqdn='',
298298
public_alias_fqdn='',
299+
status_alias_fqdn='',
299300
public_sec_fqdn='',
300301
mig_cert_fqdn='',
301302
ext_cert_fqdn='',
@@ -617,6 +618,7 @@ def _generate_confs_prepare(
617618
base_fqdn,
618619
public_fqdn,
619620
public_alias_fqdn,
621+
status_alias_fqdn,
620622
public_sec_fqdn,
621623
mig_cert_fqdn,
622624
ext_cert_fqdn,
@@ -847,6 +849,7 @@ def _generate_confs_prepare(
847849
user_dict['__BASE_FQDN__'] = base_fqdn
848850
user_dict['__PUBLIC_FQDN__'] = public_fqdn
849851
user_dict['__PUBLIC_ALIAS_FQDN__'] = public_alias_fqdn
852+
user_dict['__STATUS_ALIAS_FQDN__'] = status_alias_fqdn
850853
if public_use_https:
851854
if public_sec_fqdn:
852855
user_dict['__PUBLIC_SEC_FQDN__'] = public_sec_fqdn
@@ -1085,6 +1088,7 @@ def _generate_confs_prepare(
10851088
user_dict['__GDP_PATH_SCRAMBLE__'] = gdp_path_scramble
10861089
user_dict['__PUBLIC_HTTPS_LISTEN__'] = listen_clause
10871090
user_dict['__PUBLIC_ALIAS_HTTPS_LISTEN__'] = listen_clause
1091+
user_dict['__STATUS_ALIAS_HTTPS_LISTEN__'] = listen_clause
10881092
user_dict['__QUOTA_BACKEND__'] = quota_backend
10891093
user_dict['__QUOTA_USER_LIMIT__'] = "%s" % quota_user_limit
10901094
user_dict['__QUOTA_VGRID_LIMIT__'] = "%s" % quota_vgrid_limit
@@ -1224,6 +1228,9 @@ def _generate_confs_prepare(
12241228
user_dict['__IFDEF_PUBLIC_ALIAS_FQDN__'] = 'UnDefine'
12251229
if user_dict['__PUBLIC_ALIAS_FQDN__']:
12261230
user_dict['__IFDEF_PUBLIC_ALIAS_FQDN__'] = 'Define'
1231+
user_dict['__IFDEF_STATUS_ALIAS_FQDN__'] = 'UnDefine'
1232+
if user_dict['__STATUS_ALIAS_FQDN__']:
1233+
user_dict['__IFDEF_STATUS_ALIAS_FQDN__'] = 'Define'
12271234

12281235
user_dict['__IFDEF_MIG_CERT_FQDN__'] = 'UnDefine'
12291236
if user_dict['__MIG_CERT_FQDN__']:
@@ -2099,6 +2106,11 @@ def _generate_confs_prepare(
20992106
# Apache fails on duplicate listen clauses
21002107
if public_use_https and public_alias_fqdn == public_fqdn:
21012108
user_dict['__PUBLIC_ALIAS_HTTPS_LISTEN__'] = "# %s" % listen_clause
2109+
if status_alias_fqdn:
2110+
# Apache fails on duplicate listen clauses
2111+
if public_use_https and status_alias_fqdn in (public_fqdn,
2112+
public_alias_fqdn):
2113+
user_dict['__STATUS_ALIAS_HTTPS_LISTEN__'] = "# %s" % listen_clause
21022114

21032115
if mig_cert_fqdn:
21042116
user_dict['__MIG_CERT_URL__'] = 'https://%(__MIG_CERT_FQDN__)s' % \

tests/fixture/confs-stdlocal/MiG.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ Alias /assets/ "/home/mig/mig/assets/"
114114
Alias /public/ "/home/mig/state/wwwpublic/"
115115
# Bind security.txt (https://securitytxt.org/) once and for all
116116
Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.txt"
117+
<IfDefine STATUS_ALIAS_FQDN>
118+
# Status page helpers
119+
Alias /status.html "/home/mig/state/wwwpublic/status.html"
120+
Alias /status-events.json "/home/mig/state/wwwpublic/status-events.json"
121+
</IfDefine>
117122
<Directory "/home/mig/state/wwwpublic">
118123
AuthType none
119124
<IfVersion > 2.2>
@@ -432,6 +437,9 @@ Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.
432437
<IfDefine PUBLIC_ALIAS_FQDN>
433438
ServerAlias ${PUBLIC_ALIAS_FQDN}
434439
</IfDefine>
440+
<IfDefine STATUS_ALIAS_FQDN>
441+
ServerAlias ${STATUS_ALIAS_FQDN}
442+
</IfDefine>
435443
# Optionally add extra server aliases for current and future use here
436444
#ServerAlias something. somethingelse.
437445

@@ -475,6 +483,11 @@ Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.
475483
RewriteCond %{HTTP_HOST} ^${PUBLIC_ALIAS_FQDN}$
476484
RewriteRule ^/?(.*) https://${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}/$1 [R,L]
477485
</IfDefine>
486+
<IfDefine STATUS_ALIAS_FQDN>
487+
RewriteCond %{HTTPS} off
488+
RewriteCond %{HTTP_HOST} ^${STATUS_ALIAS_FQDN}$
489+
RewriteRule ^/?(.*) https://${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}/$1 [R,L]
490+
</IfDefine>
478491
</IfDefine>
479492

480493
# NOTE: redirect all remaining enabled protected address requests to https
@@ -609,6 +622,9 @@ Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.
609622
<VirtualHost ${PUBLIC_FQDN}:${PUBLIC_HTTPS_PORT}>
610623
ServerName ${PUBLIC_FQDN}
611624
ServerAlias
625+
<IfDefine STATUS_ALIAS_FQDN>
626+
ServerAlias ${STATUS_ALIAS_FQDN}
627+
</IfDefine>
612628
# Optionally add extra server aliases for current and future use here
613629
#ServerAlias something. somethingelse.
614630

@@ -660,6 +676,12 @@ Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.
660676
RewriteLogLevel 0
661677
</IfVersion>
662678

679+
<IfDefine STATUS_ALIAS_FQDN>
680+
# Redirect implict target to status page
681+
RewriteCond %{SERVER_NAME} ^${STATUS_ALIAS_FQDN}$
682+
RewriteRule ^(/*)$ /status.html [L,R]
683+
</IfDefine>
684+
663685
# Break rewriting chain for commonly-requested final destinations
664686
# * Direct files (including subrequest for /X.py from /wsgi-bin/X.py)
665687
# * Xgi scripts
@@ -734,6 +756,9 @@ Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.
734756
<IfDefine PUBLIC_ALIAS_FQDN>
735757
<VirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}>
736758
ServerName ${PUBLIC_ALIAS_FQDN}
759+
<IfDefine STATUS_ALIAS_FQDN>
760+
ServerAlias ${STATUS_ALIAS_FQDN}
761+
</IfDefine>
737762
# General setup for the virtual host
738763
DocumentRoot "/home/mig/state/wwwpublic"
739764
ErrorLog /var/log/apache2/ssl-error.log
@@ -774,6 +799,12 @@ Alias /.well-known/security.txt "/home/mig/state/wwwpublic/.well-known/security.
774799
RewriteLogLevel 0
775800
</IfVersion>
776801

802+
<IfDefine STATUS_ALIAS_FQDN>
803+
# Redirect implict target to status page
804+
RewriteCond %{SERVER_NAME} ^${STATUS_ALIAS_FQDN}$
805+
RewriteRule ^(/*)$ /status.html [L,R]
806+
</IfDefine>
807+
777808
# Break rewriting chain for commonly-requested final destinations
778809
# * Internal Aliased helper locations
779810
RewriteCond %{QUERY_STRING} ^$

tests/fixture/confs-stdlocal/apache2.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ IncludeOptional /etc/apache2/production-mode*.conf
4848
# Always-on vhosts both for emergency and production mode
4949
UnDefine PUBLIC_FQDN
5050
UnDefine PUBLIC_ALIAS_FQDN
51+
UnDefine STATUS_ALIAS_FQDN
5152
# User vhosts are ONLY enabled in actual production mode
5253
<IfDefine PRODUCTION_MODE>
5354
UnDefine BASE_FQDN

tests/fixture/confs-stdlocal/ports.conf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ Listen ${PUBLIC_HTTP_PORT}
3333
</IfDefine>
3434
<IfDefine PUBLIC_ALIAS_FQDN>
3535
<IfDefine PUBLIC_HTTPS_PORT>
36-
<IfDefine PRODUCTION_MODE>
3736
#NameVirtualHost ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
3837
#Listen ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
3938
</IfDefine>
40-
<IfDefine !PRODUCTION_MODE>
41-
# Also force listen on PUBLIC_ALIAS_FQDN here if not in PRODUCTION_MODE
42-
Listen ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
4339
</IfDefine>
40+
<IfDefine STATUS_ALIAS_FQDN>
41+
<IfDefine PUBLIC_HTTPS_PORT>
42+
#NameVirtualHost ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
43+
#Listen ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
4444
</IfDefine>
4545
</IfDefine>
4646
<IfDefine MIG_CERT_FQDN>
@@ -70,6 +70,12 @@ Listen ${PUBLIC_HTTP_PORT}
7070
#Listen ${PUBLIC_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
7171
</IfDefine>
7272
</IfDefine>
73+
<IfDefine STATUS_ALIAS_FQDN>
74+
<IfDefine PUBLIC_HTTPS_PORT>
75+
#NameVirtualHost ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
76+
#Listen ${STATUS_ALIAS_FQDN}:${PUBLIC_HTTPS_PORT}
77+
</IfDefine>
78+
</IfDefine>
7379
<IfDefine MIG_CERT_FQDN>
7480
<IfDefine MIG_CERT_PORT>
7581
#NameVirtualHost ${MIG_CERT_FQDN}:${MIG_CERT_PORT}

0 commit comments

Comments
 (0)