Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 69b98b6

Browse files
committed
Merge pull request #53 from jdeathe/issue/44
ISSUE 44: Disabled ExtendedStatus by default and added option for ope…
2 parents c5c56f5 + 33e45ca commit 69b98b6

File tree

8 files changed

+84
-15
lines changed

8 files changed

+84
-15
lines changed

README.md

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,30 @@ $ docker run -d \
4646

4747
Now point your browser to ```http://<docker-host>:8080``` where "```<docker-host>```" is the host name of your docker server and, if all went well, you should see the "Hello, world!" page.
4848

49-
![Hello World Screen Shot](https://raw.github.com/jdeathe/centos-ssh-apache-php-fcgi/centos-6/images/hello-world.png)
49+
![Hello World - PHP FastCGI Screen Shot - Chrome](https://raw.github.com/jdeathe/centos-ssh-apache-php/centos-6/images/hello-world-php-fcgi-chrome.png)
50+
51+
To be able to access the server using the "app-1.local" domain name you need to add a hosts file entry locally; such that the IP address of the Docker host resolves to the name "app-1.local". Alternatively, you can use the elinks browser installed in the container. Note that because you are using the browser from the container you access the site over port 80.
52+
53+
```
54+
$ docker exec -it apache-php.app-1.1.1 \
55+
elinks http://app-1.local
56+
```
57+
58+
![Hello World - PHP FastCGI Screen Shot - eLinks](https://raw.github.com/jdeathe/centos-ssh-apache-php/centos-6/images/hello-world-php-fcgi-elinks.png)
59+
60+
To verify the container is initialised and running successfully by inspecting the container's logs.
61+
62+
```
63+
$ docker logs apache-php.app-1.1.1
64+
```
65+
66+
On first run, the bootstrap script, ([/etc/apache-bootstrap](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/apache-bootstrap)), will check if the DocumentRoot directory is empty and, if so, will populate it with the example app scripts and VirtualHost configuration files. If you place your own app in this directory it will not be overwritten but you must ensure to include at least a vhost.conf file and, if enabling SSL a vhost-ssl.conf file too.
67+
68+
The ```apachectl``` command can be accessed as follows.
69+
70+
```
71+
$ docker exec -it apache-php.app-1.1.1 apachectl -h
72+
```
5073

5174
## Instructions
5275

@@ -91,10 +114,11 @@ $ docker run -d \
91114
--env "SERVICE_UNIT_INSTANCE=app-1" \
92115
--env "SERVICE_UNIT_LOCAL_ID=1" \
93116
--env "SERVICE_UNIT_INSTANCE=1" \
94-
--env "APACHE_SERVER_ALIAS=app-1" \
95-
--env "APACHE_SERVER_NAME=app-1.local" \
117+
--env "APACHE_EXTENDED_STATUS_ENABLED=false" \
96118
--env "APACHE_LOAD_MODULES=authz_user_module log_config_module expires_module deflate_module headers_module setenvif_module mime_module status_module dir_module alias_module rewrite_module" \
97119
--env "APACHE_MOD_SSL_ENABLED=false" \
120+
--env "APACHE_SERVER_ALIAS=app-1" \
121+
--env "APACHE_SERVER_NAME=app-1.local" \
98122
--env "APP_HOME_DIR=/var/www/app-1" \
99123
--env "DATE_TIMEZONE=UTC" \
100124
--env "SERVICE_USER=app" \
@@ -162,7 +186,26 @@ The ```APACHE_SERVER_NAME``` and ```APACHE_SERVER_ALIAS``` environmental variabl
162186

163187
from your browser you can then access it with ```http://app-1.local:8080``` assuming you have the IP address of your docker mapped to the hostname using your DNS server or a local hosts entry.
164188

165-
##### 3. APACHE_LOAD_MODULES
189+
##### 3. APACHE_EXTENDED_STATUS_ENABLED
190+
191+
The variable ```APACHE_EXTENDED_STATUS_ENABLED``` allows you to turn ExtendedStatus on. It is turned off by default as it has an impact on the server's performance but with it enabled you can gather more statistics.
192+
193+
```
194+
...
195+
--env "APACHE_EXTENDED_STATUS_ENABLED=true"
196+
...
197+
```
198+
199+
You can view the output from Apache server-status either using the elinks browser from onboard the container or by using `watch` and `curl` to monitor status over time - the following command shows the server-status updated at a 1 second interval.
200+
201+
```
202+
$ docker exec -it apache-php.app-1.1.1 \
203+
env TERM=xterm \
204+
watch -n 10 \
205+
-d "curl -s http://app-1/_httpdstatus?auto"
206+
```
207+
208+
##### 4. APACHE_LOAD_MODULES
166209

167210
The variable ```APACHE_LOAD_MODULES``` defines all Apache modules to be loaded from */etc/httpd/conf/http.conf*. The default is the minimum required so you may need to add more as necessary. To add the "mod\_rewrite" Apache Module you would add it's identifier ```rewrite_module``` to the array as follows.
168211

@@ -172,7 +215,7 @@ The variable ```APACHE_LOAD_MODULES``` defines all Apache modules to be loaded f
172215
...
173216
```
174217

175-
##### 4. APACHE_MOD_SSL_ENABLED
218+
##### 5. APACHE_MOD_SSL_ENABLED
176219

177220
By default SSL support is disabled but a second port, (mapped to 8443), is available for traffic that has been been through upstream SSL termination (SSL Offloading). If you want the container to support SSL directly then set ```APACHE_MOD_SSL_ENABLED=true``` this will then generate a self signed certificate and will update Apache to accept traffic on port 443.
178221

@@ -196,7 +239,7 @@ $ docker run -d \
196239
jdeathe/centos-ssh-apache-php-fcgi:latest
197240
```
198241

199-
##### 5. APP_HOME_DIR
242+
##### 6. APP_HOME_DIR
200243

201244
The home directory of the service user and parent directory of the Apache DocumentRoot is /var/www/app by default but can be changed if necessary using the ```APP_HOME_DIR``` environment variable. It is also necessary to change the target of the data volume mapping accordingly as in the following example where /var/www/app-1 is used.
202245

@@ -207,7 +250,7 @@ The home directory of the service user and parent directory of the Apache Docume
207250
...
208251
```
209252

210-
##### 6. DATE_TIMEZONE
253+
##### 7. DATE_TIMEZONE
211254

212255
The default timezone for the container, and the PHP app, is UTC however the operator can set an appropriate timezone using the ```DATE_TIMEZONE``` variable. The value should be a timezone identifier, like UTC or Europe/London. The list of valid identifiers is available in the PHP [List of Supported Timezones](http://php.net/manual/en/timezones.php).
213256

@@ -219,7 +262,7 @@ To set the timezone for the UK and account for British Summer Time you would use
219262
...
220263
```
221264

222-
##### 7. SERVICE_USER, SERVICE_USER_GROUP & SERVICE_USER_PASSWORD
265+
##### 8. SERVICE_USER, SERVICE_USER_GROUP & SERVICE_USER_PASSWORD
223266

224267
Use the ```SERVICE_USER```, ```SERVICE_USER_GROUP``` and ```SERVICE_USER_PASSWORD``` environment variables to define a custom service username, group and password respectively. If the password is left an empty string then it is automatically generated on first run which is the default.
225268

@@ -266,5 +309,3 @@ The supervisor service's configuration can also be overridden by editing the cus
266309
### Apache DocumentRoot - Data Directory
267310

268311
In the previous example Docker run commands we mapped the Docker host directory ```/var/services-data/apache-php/app-1``` to ```/var/www/app``` in the Docker container, where ```/var/services-data/``` is the directory used to store persistent files and the subdirectory is used by an individual app's named container(s), ```apache-php.app-1.1.1```, in the previous examples.
269-
270-
On first run, the bootstrap script, ([/etc/apache-bootstrap](https://github.com/jdeathe/centos-ssh-apache-php-fcgi/blob/centos-6/etc/apache-bootstrap)), will check if the DocumentRoot directory is empty and, if so, will populate it with the example app scripts and VirtualHost configuration files. If you place your own app in this directory it will not be overwritten but you must ensure to include at least a vhost.conf file and, if enabling SSL a vhost-ssl.conf file too.

etc/apache-bootstrap

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ get_password ()
2929
echo $(head -n 4096 /dev/urandom | tr -cd '[:alnum:]' | head -c ${1})
3030
}
3131

32+
set_apache_extended_status ()
33+
{
34+
local ENABLED=${1:-false}
35+
local PATTERN_FROM
36+
local PATTERN_TO
37+
38+
if [[ ${ENABLED} == true ]]; then
39+
echo "Enabling ExtendedStatus."
40+
PATTERN_FROM="^[#]?ExtendedStatus (On|on|Off|off)$"
41+
PATTERN_TO="ExtendedStatus On"
42+
else
43+
PATTERN_FROM="^ExtendedStatus (On|on)$"
44+
PATTERN_TO="#ExtendedStatus On"
45+
fi
46+
47+
sed -i \
48+
-re "s~${PATTERN_FROM}~${PATTERN_TO}~g" \
49+
/etc/httpd/conf/httpd.conf
50+
}
51+
3252
set_apache_server_name ()
3353
{
3454
local HOST_NAME=${1:-${APACHE_SERVER_NAME:-$(hostname)}}
@@ -41,10 +61,11 @@ set_apache_server_name ()
4161

4262
APP_HOME_DIR_TEMPLATE="/var/www/.app-skel"
4363

44-
OPTS_APACHE_SERVER_ALIAS="${APACHE_SERVER_ALIAS:-}"
45-
OPTS_APACHE_SERVER_NAME="${APACHE_SERVER_NAME:-$(hostname)}"
64+
OPTS_APACHE_EXTENDED_STATUS_ENABLED="${APACHE_EXTENDED_STATUS_ENABLED:-false}"
4665
OPTS_APACHE_LOAD_MODULES="${APACHE_LOAD_MODULES:-authz_user_module log_config_module expires_module deflate_module headers_module setenvif_module mime_module status_module dir_module alias_module reqtimeout_module}"
4766
OPTS_APACHE_MOD_SSL_ENABLED="${APACHE_MOD_SSL_ENABLED:-false}"
67+
OPTS_APACHE_SERVER_ALIAS="${APACHE_SERVER_ALIAS:-}"
68+
OPTS_APACHE_SERVER_NAME="${APACHE_SERVER_NAME:-$(hostname)}"
4869
OPTS_APP_HOME_DIR="${APP_HOME_DIR:-/var/www/app}"
4970
OPTS_SERVICE_USER="${SERVICE_USER:-app}"
5071
OPTS_SERVICE_USER_GROUP="${SERVICE_USER_GROUP:-app-www}"
@@ -94,6 +115,9 @@ fi
94115
# Add local hosts entries
95116
add_hosts_entry 127.0.0.1 ${OPTS_APACHE_SERVER_NAME}${OPTS_APACHE_SERVER_ALIAS:+ }${OPTS_APACHE_SERVER_ALIAS}
96117

118+
# Set ExtendedStatus
119+
set_apache_extended_status ${OPTS_APACHE_EXTENDED_STATUS_ENABLED}
120+
97121
# Add ServerName
98122
set_apache_server_name ${OPTS_APACHE_SERVER_NAME} 80
99123

etc/services-config/httpd/apache-bootstrap.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ SERVICE_UNIT_APP_GROUP="${SERVICE_UNIT_APP_GROUP:-app-1}"
1515
SERVICE_UNIT_LOCAL_ID="${SERVICE_UNIT_LOCAL_ID:-1}"
1616
SERVICE_UNIT_INSTANCE="${SERVICE_UNIT_INSTANCE:-1}"
1717

18-
APACHE_SERVER_ALIAS="${APACHE_SERVER_ALIAS:-}"
19-
APACHE_SERVER_NAME="${APACHE_SERVER_NAME:-${SERVICE_UNIT_APP_GROUP}.local}"
18+
APACHE_EXTENDED_STATUS_ENABLED="${APACHE_EXTENDED_STATUS_ENABLED:-false}"
2019
APACHE_LOAD_MODULES="${APACHE_LOAD_MODULES:-${APACHE_LOAD_MODULES_DEFAULT}}"
2120
APACHE_MOD_SSL_ENABLED="${APACHE_MOD_SSL_ENABLED:-false}"
21+
APACHE_SERVER_ALIAS="${APACHE_SERVER_ALIAS:-}"
22+
APACHE_SERVER_NAME="${APACHE_SERVER_NAME:-${SERVICE_UNIT_APP_GROUP}.local}"
2223
APP_HOME_DIR="${APP_HOME_DIR:-/var/www/app}"
2324
DATE_TIMEZONE="${DATE_TIMEZONE:-UTC}"
2425
HTTPD="${HTTPD:-/usr/sbin/httpd}"

etc/services-config/httpd/conf/httpd.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Include conf.d/*.conf
225225
# information (ExtendedStatus On) or just basic information (ExtendedStatus
226226
# Off) when the "server-status" handler is called. The default is Off.
227227
#
228-
ExtendedStatus On
228+
#ExtendedStatus On
229229

230230
#
231231
# If you wish httpd to run as a different user or group, you must run
54.8 KB
Loading
29.6 KB
Loading

run.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ APACHE_LOAD_MODULES_DEFAULT="
4343
alias_module
4444
"
4545

46+
APACHE_EXTENDED_STATUS_ENABLED=false
4647
APACHE_LOAD_MODULES="${APACHE_LOAD_MODULES_DEFAULT}"
4748
APACHE_MOD_SSL_ENABLED=false
4849
APACHE_SERVER_ALIAS=app-1

run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ docker run \
151151
--env "SERVICE_UNIT_APP_GROUP=${SERVICE_UNIT_APP_GROUP}" \
152152
--env "SERVICE_UNIT_LOCAL_ID=${SERVICE_UNIT_LOCAL_ID}" \
153153
--env "SERVICE_UNIT_INSTANCE=${SERVICE_UNIT_INSTANCE}" \
154+
--env "APACHE_EXTENDED_STATUS_ENABLED=${APACHE_EXTENDED_STATUS_ENABLED}" \
154155
--env "APACHE_LOAD_MODULES=${APACHE_LOAD_MODULES}" \
155156
--env "APACHE_MOD_SSL_ENABLED=${APACHE_MOD_SSL_ENABLED}" \
156157
--env "APACHE_SERVER_ALIAS=${APACHE_SERVER_ALIAS}" \
@@ -180,6 +181,7 @@ docker run \
180181
# --env "SERVICE_UNIT_APP_GROUP=app-1" \
181182
# --env "SERVICE_UNIT_LOCAL_ID=1" \
182183
# --env "SERVICE_UNIT_INSTANCE=1" \
184+
# --env "APACHE_EXTENDED_STATUS_ENABLED=true"
183185
# --env "APACHE_LOAD_MODULES=${APACHE_LOAD_MODULES} rewrite_module" \
184186
# --env "APACHE_MOD_SSL_ENABLED=false" \
185187
# --env "APACHE_SERVER_ALIAS=app-1 www.app-1 www.app-1.local" \

0 commit comments

Comments
 (0)