Skip to content

Commit 45bf1d4

Browse files
authored
ci(nix): Startup/configure apache for renegotiate test under nix (#4592)
1 parent 9cca574 commit 45bf1d4

File tree

5 files changed

+955
-10
lines changed

5 files changed

+955
-10
lines changed

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
corretto
3030
pkgs.iproute2
3131
pkgs.apacheHttpd
32+
pkgs.procps
3233
# GnuTLS-cli and serv utilities needed for some integration tests.
3334
pkgs.gnutls
3435
pkgs.gdb

nix/shell.sh

+34-10
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,11 @@ function unit {
6262
}
6363

6464
function integ {
65-
if [ "$1" == "help" ]; then
66-
echo "The following tests are not supported:"
67-
echo "- renegotiate_apache"
68-
echo " This test requires apache to be running. See codebuild/bin/s2n_apache.sh"
69-
echo " for more info."
70-
return
71-
fi
65+
apache2_start
7266
if [[ -z "$1" ]]; then
73-
banner "Running all integ tests except renegotiate_apache."
74-
(cd $SRC_ROOT/build; ctest -L integrationv2 -E "(integrationv2_cross_compatibility|integrationv2_renegotiate_apache)" --verbose)
67+
banner "Running all integ tests."
68+
(cd $SRC_ROOT/build; ctest -L integrationv2 --verbose)
7569
else
76-
banner "Warning: renegotiate_apache is not supported in nix for various reasons integ help for more info."
7770
for test in $@; do
7871
ctest --test-dir ./build -L integrationv2 --no-tests=error --output-on-failure -R "$test" --verbose
7972
if [ "$?" -ne 0 ]; then
@@ -159,3 +152,34 @@ function test_nonstandard_compilation {
159152
./codebuild/bin/test_dynamic_load.sh $(mktemp -d)
160153
}
161154

155+
function apache2_config(){
156+
export APACHE_NIX_STORE=$(dirname $(dirname $(which httpd)))
157+
export APACHE2_INSTALL_DIR=/usr/local/apache2
158+
export APACHE_SERVER_ROOT="$APACHE2_INSTALL_DIR"
159+
export APACHE_RUN_USER=nobody
160+
# Unprivileged groupname differs
161+
export APACHE_RUN_GROUP=$(awk 'BEGIN{FS=":"} /65534/{print $1}' /etc/group)
162+
export APACHE_PID_FILE="${APACHE2_INSTALL_DIR}/run/apache2.pid"
163+
export APACHE_RUN_DIR="${APACHE2_INSTALL_DIR}/run"
164+
export APACHE_LOCK_DIR="${APACHE2_INSTALL_DIR}/lock"
165+
export APACHE_LOG_DIR="${APACHE2_INSTALL_DIR}/log"
166+
export APACHE_CERT_DIR="$SRC_ROOT/tests/pems"
167+
}
168+
169+
function apache2_start(){
170+
if [[ "$(pgrep -c httpd)" -eq "0" ]]; then
171+
apache2_config
172+
if [[ ! -f "$APACHE2_INSTALL_DIR/conf/apache2.conf" ]]; then
173+
mkdir -p $APACHE2_INSTALL_DIR/{run,log,lock}
174+
# NixOs specific base apache config
175+
cp -R ./tests/integrationv2/apache2/nix/* $APACHE2_INSTALL_DIR
176+
# Integrationv2::renegotiate site
177+
cp -R ./codebuild/bin/apache2/{www,sites-enabled} $APACHE2_INSTALL_DIR
178+
fi
179+
httpd -k start -f "${APACHE2_INSTALL_DIR}/conf/apache2.conf"
180+
trap 'pkill httpd' ERR EXIT
181+
else
182+
echo "Apache is already running...and if \"$APACHE2_INSTALL_DIR\" is stale, it might be in an unknown state."
183+
fi
184+
185+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Consolidated apache2.conf, mods-enabled/* and conf-enabled/*.
2+
ServerRoot ${APACHE_SERVER_ROOT}
3+
DefaultRuntimeDir ${APACHE_RUN_DIR}
4+
PidFile ${APACHE_PID_FILE}
5+
Timeout 60
6+
KeepAlive On
7+
MaxKeepAliveRequests 100
8+
KeepAliveTimeout 5
9+
HostnameLookups Off
10+
ErrorLog ${APACHE_LOG_DIR}/error.log
11+
LogLevel info
12+
13+
# Inline load module
14+
LoadModule access_compat_module ${APACHE_NIX_STORE}/modules/mod_access_compat.so
15+
LoadModule alias_module ${APACHE_NIX_STORE}/modules/mod_alias.so
16+
LoadModule auth_basic_module ${APACHE_NIX_STORE}/modules/mod_auth_basic.so
17+
LoadModule authn_core_module ${APACHE_NIX_STORE}/modules/mod_authn_core.so
18+
LoadModule authn_file_module ${APACHE_NIX_STORE}/modules/mod_authn_file.so
19+
LoadModule authz_core_module ${APACHE_NIX_STORE}/modules/mod_authz_core.so
20+
LoadModule authz_host_module ${APACHE_NIX_STORE}/modules/mod_authz_host.so
21+
LoadModule authz_user_module ${APACHE_NIX_STORE}/modules/mod_authz_user.so
22+
LoadModule autoindex_module ${APACHE_NIX_STORE}/modules/mod_autoindex.so
23+
LoadModule dir_module ${APACHE_NIX_STORE}/modules/mod_dir.so
24+
LoadModule deflate_module ${APACHE_NIX_STORE}/modules/mod_deflate.so
25+
LoadModule env_module ${APACHE_NIX_STORE}/modules/mod_env.so
26+
LoadModule filter_module ${APACHE_NIX_STORE}/modules/mod_filter.so
27+
LoadModule log_config_module ${APACHE_NIX_STORE}/modules/mod_log_config.so
28+
LoadModule mime_module ${APACHE_NIX_STORE}/modules/mod_mime.so
29+
LoadModule mpm_event_module ${APACHE_NIX_STORE}/modules/mod_mpm_event.so
30+
LoadModule reqtimeout_module ${APACHE_NIX_STORE}/modules/mod_reqtimeout.so
31+
LoadModule rewrite_module ${APACHE_NIX_STORE}/modules/mod_rewrite.so
32+
LoadModule setenvif_module ${APACHE_NIX_STORE}/modules/mod_setenvif.so
33+
LoadModule socache_shmcb_module ${APACHE_NIX_STORE}/modules/mod_socache_shmcb.so
34+
LoadModule ssl_module ${APACHE_NIX_STORE}/modules/mod_ssl.so
35+
LoadModule status_module ${APACHE_NIX_STORE}/modules/mod_status.so
36+
LoadModule unixd_module ${APACHE_NIX_STORE}/modules/mod_unixd.so
37+
38+
# Include list of ports to listen on
39+
Include conf/ports.conf
40+
41+
<IfModule unixd_module>
42+
User ${APACHE_RUN_USER}
43+
Group ${APACHE_RUN_GROUP}
44+
</IfModule>
45+
46+
DocumentRoot ${APACHE_SERVER_ROOT}/www/html
47+
<Directory />
48+
Options FollowSymLinks
49+
AllowOverride None
50+
Require all denied
51+
</Directory>
52+
53+
<Directory ${APACHE_SERVER_ROOT}/www/html>
54+
Options Indexes FollowSymLinks
55+
AllowOverride None
56+
Require all granted
57+
</Directory>
58+
59+
AccessFileName .htaccess
60+
61+
LogFormat "%v:%p %h %l %u %t \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
62+
LogFormat "%h %l %u %t \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" combined
63+
LogFormat "%h %l %u %t \"%r\" %>s " common
64+
LogFormat "%{Referer}i -> %U" referer
65+
LogFormat "%{User-agent}i" agent
66+
CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined
67+
68+
# Include the virtual host configurations:
69+
IncludeOptional sites-enabled/*.conf
70+
71+
# inline module configs
72+
<IfModule mod_mime.c>
73+
TypesConfig ${APACHE_NIX_STORE}/conf/mime.types
74+
AddType application/x-compress .Z
75+
AddType application/x-gzip .gz .tgz
76+
AddType application/x-bzip2 .bz2
77+
AddLanguage en .en
78+
AddCharset us-ascii .ascii .us-ascii
79+
AddCharset ISO-8859-1 .iso8859-1 .latin1
80+
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
81+
AddCharset ISO-8859-3 .iso8859-3 .latin3
82+
AddCharset ISO-8859-4 .iso8859-4 .latin4
83+
AddCharset ISO-8859-9 .iso8859-9 .latin5 .trk
84+
AddCharset ISO-8859-10 .iso8859-10 .latin6
85+
AddCharset ISO-8859-13 .iso8859-13
86+
AddCharset ISO-8859-14 .iso8859-14 .latin8
87+
AddCharset ISO-8859-15 .iso8859-15 .latin9
88+
AddCharset ISO-8859-16 .iso8859-16 .latin10
89+
# For russian, more than one charset is used (depends on client, mostly):
90+
AddCharset WINDOWS-1251 .cp-1251 .win-1251
91+
AddCharset CP866 .cp866
92+
AddCharset ISO-10646-UCS-2 .ucs2
93+
AddCharset ISO-10646-UCS-4 .ucs4
94+
AddCharset UTF-7 .utf7
95+
AddCharset UTF-8 .utf8
96+
AddCharset UTF-16 .utf16
97+
AddCharset UTF-16BE .utf16be
98+
AddCharset UTF-16LE .utf16le
99+
AddCharset iso-10646-ucs-2 .ucs-2 .iso-10646-ucs-2
100+
AddCharset iso-10646-ucs-4 .ucs-4 .iso-10646-ucs-4
101+
AddCharset shift_jis .shift_jis .sjis
102+
AddCharset BRF .brf
103+
104+
AddHandler type-map var
105+
AddType text/html .shtml
106+
<IfModule mod_include.c>
107+
AddOutputFilter INCLUDES .shtml
108+
</IfModule>
109+
110+
</IfModule>
111+
112+
<IfModule mod_ssl.c>
113+
SSLRandomSeed startup builtin
114+
SSLRandomSeed startup file:/dev/urandom 512
115+
SSLRandomSeed connect builtin
116+
SSLRandomSeed connect file:/dev/urandom 512
117+
AddType application/x-x509-ca-cert .crt
118+
AddType application/x-pkcs7-crl .crl
119+
SSLSessionCache shmcb:${APACHE_RUN_DIR}/ssl_scache(512000)
120+
SSLSessionCacheTimeout 300
121+
SSLCipherSuite HIGH:!aNULL
122+
SSLProtocol all -SSLv3
123+
</IfModule>
124+
125+
<IfModule mod_negotiation.c>
126+
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW
127+
ForceLanguagePriority Prefer Fallback
128+
</IfModule>
129+
<IfModule mpm_event_module>
130+
StartServers 2
131+
MinSpareThreads 25
132+
MaxSpareThreads 75
133+
ThreadLimit 64
134+
ThreadsPerChild 25
135+
MaxRequestWorkers 150
136+
MaxConnectionsPerChild 0
137+
</IfModule>
138+
<IfModule reqtimeout_module>
139+
RequestReadTimeout header=20-40,minrate=500
140+
RequestReadTimeout body=10,minrate=500
141+
</IfModule>
142+
143+
# === end module configs
144+
145+
146+
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

0 commit comments

Comments
 (0)