Skip to content

Commit f7d0ff7

Browse files
flightcomphiltrep
authored andcommitted
Adds Apache2 as new Proxy Webserver option (#87)
* Adds Apache2 as new Proxy Webserver option * Adds Apache2 log support * Removes useless ProxyPassReverse option for Apache Container * Adds example for Apache * Remvoes comments from httpd config file * Adds shared folder for sharing resources between Apache and Nginx * Cleaning * Adds shared directories * Removes shared directories as it does not work * Updates README with new Apache example
1 parent 46e8aa5 commit f7d0ff7

File tree

18 files changed

+307
-33
lines changed

18 files changed

+307
-33
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ services:
8282
## Examples
8383
We provide examples of configurations you might use for a specific stack. Each example has it's own README file with instructions.
8484
85-
* [Simple Web](https://github.com/Osedea/nodock/tree/master/_examples/simple-web) - Node + NGINX
85+
* [Simple Web with Apache](https://github.com/Osedea/nodock/tree/master/_examples/apache) - Node + Apache
86+
* [Simple Web with Nginx](https://github.com/Osedea/nodock/tree/master/_examples/nginx) - Node + NGINX
8687
* [MySQL](https://github.com/Osedea/nodock/tree/master/_examples/mysql) - MySQL + Node + NGINX
8788
* [Mongo](https://github.com/Osedea/nodock/tree/master/_examples/mongo) - MongoDB + Node + NGINX
8889
* [RabbitMQ](https://github.com/Osedea/nodock/tree/master/_examples/rabbitmq) - RabbitMQ + Node + NGINX

_examples/apache/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Simple Web Service
2+
3+
### Setup
4+
5+
Copy the index file in this folder to the project root:
6+
7+
```bash
8+
cd <project_folder>/
9+
10+
cp -r nodock/_examples/apache/* .
11+
```
12+
13+
### Usage
14+
15+
```bash
16+
cd nodock/
17+
18+
docker-compose up -d node apache
19+
```
20+
21+
By going to `127.0.0.1` in your browser you should be seeing a nice greeting!
File renamed without changes.
File renamed without changes.

_examples/simple-web/README.md renamed to _examples/nginx/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Copy the index file in this folder to the project root:
77
```bash
88
cd <project_folder>/
99

10-
cp -r nodock/_examples/simple-web/* .
10+
cp -r nodock/_examples/nginx/* .
1111
```
1212

1313
### Usage

_examples/nginx/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var express = require('express');
2+
var app = express();
3+
4+
app.get('/', function(req, res) {
5+
res.send('You are amazing');
6+
});
7+
8+
app.listen(8000);

_examples/nginx/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "example-simple-web-node-docker",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "MIT",
11+
"dependencies": {
12+
"express": "^4.14.0"
13+
}
14+
}

apache/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM httpd:2.4
2+
3+
# openssl not installed in image
4+
RUN apt-get update && apt-get install openssl
5+
6+
RUN mkdir /usr/local/apache2/templates \
7+
&& mkdir /usr/local/apache2/sites-available \
8+
&& rm /usr/local/apache2/conf/httpd.conf \
9+
&& rm /usr/local/apache2/conf/extra/*.conf
10+
ADD httpd.conf /usr/local/apache2/conf
11+
12+
COPY scripts /root/scripts/
13+
COPY certs/* /etc/ssl/
14+
15+
COPY sites /usr/local/apache2/templates
16+
17+
ARG WEB_REVERSE_PROXY_PORT=8000
18+
ARG WEB_SSL=false
19+
ARG SELF_SIGNED=false
20+
ARG NO_DEFAULT=false
21+
22+
ENV WEB_REVERSE_PROXY_PORT=$WEB_REVERSE_PROXY_PORT
23+
ENV WEB_SSL=$WEB_SSL
24+
ENV SELF_SIGNED=$SELF_SIGNED
25+
ENV NO_DEFAULT=$NO_DEFAULT
26+
27+
RUN /bin/bash /root/scripts/build-apache.sh
28+
29+
CMD ["apachectl", "-D", "FOREGROUND"]

apache/httpd.conf

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
ServerRoot "/usr/local/apache2"
2+
3+
LoadModule authn_file_module modules/mod_authn_file.so
4+
LoadModule authn_core_module modules/mod_authn_core.so
5+
LoadModule authz_host_module modules/mod_authz_host.so
6+
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
7+
LoadModule authz_user_module modules/mod_authz_user.so
8+
LoadModule authz_core_module modules/mod_authz_core.so
9+
LoadModule access_compat_module modules/mod_access_compat.so
10+
LoadModule auth_basic_module modules/mod_auth_basic.so
11+
LoadModule reqtimeout_module modules/mod_reqtimeout.so
12+
LoadModule filter_module modules/mod_filter.so
13+
LoadModule mime_module modules/mod_mime.so
14+
LoadModule log_config_module modules/mod_log_config.so
15+
LoadModule env_module modules/mod_env.so
16+
LoadModule headers_module modules/mod_headers.so
17+
LoadModule setenvif_module modules/mod_setenvif.so
18+
LoadModule version_module modules/mod_version.so
19+
LoadModule proxy_module modules/mod_proxy.so
20+
LoadModule proxy_http_module modules/mod_proxy_http.so
21+
LoadModule ssl_module modules/mod_ssl.so
22+
LoadModule unixd_module modules/mod_unixd.so
23+
LoadModule status_module modules/mod_status.so
24+
LoadModule autoindex_module modules/mod_autoindex.so
25+
LoadModule dir_module modules/mod_dir.so
26+
LoadModule alias_module modules/mod_alias.so
27+
28+
<IfModule unixd_module>
29+
User www-data
30+
Group www-data
31+
32+
</IfModule>
33+
34+
ServerAdmin [email protected]
35+
36+
<Directory />
37+
AllowOverride none
38+
Require all denied
39+
</Directory>
40+
41+
DocumentRoot "/usr/local/apache2/htdocs"
42+
<Directory "/usr/local/apache2/htdocs">
43+
Options Indexes FollowSymLinks
44+
AllowOverride None
45+
Require all granted
46+
</Directory>
47+
48+
<IfModule dir_module>
49+
DirectoryIndex index.html
50+
</IfModule>
51+
52+
<Files ".ht*">
53+
Require all denied
54+
</Files>
55+
56+
ErrorLog /proc/self/fd/2
57+
LogLevel warn
58+
59+
<IfModule log_config_module>
60+
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
61+
LogFormat "%h %l %u %t \"%r\" %>s %b" common
62+
63+
<IfModule logio_module>
64+
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
65+
</IfModule>
66+
67+
CustomLog /proc/self/fd/1 common
68+
69+
</IfModule>
70+
71+
<IfModule alias_module>
72+
ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
73+
</IfModule>
74+
75+
<Directory "/usr/local/apache2/cgi-bin">
76+
AllowOverride None
77+
Options None
78+
Require all granted
79+
</Directory>
80+
81+
<IfModule headers_module>
82+
RequestHeader unset Proxy early
83+
</IfModule>
84+
85+
<IfModule mime_module>
86+
TypesConfig conf/mime.types
87+
AddType application/x-compress .Z
88+
AddType application/x-gzip .gz .tgz
89+
</IfModule>
90+
91+
Include sites-available/*.conf
92+
93+
<IfModule proxy_html_module>
94+
Include conf/extra/proxy-html.conf
95+
</IfModule>
96+
97+
<IfModule ssl_module>
98+
SSLRandomSeed startup builtin
99+
SSLRandomSeed connect builtin
100+
</IfModule>

apache/scripts/build-apache.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
for conf in /usr/local/apache2/templates/*.conf; do
4+
mv $conf "/usr/local/apache2/sites-available/"$(basename $conf) > /dev/null
5+
done
6+
7+
for template in /usr/local/apache2/templates/*.template; do
8+
mv $template "/usr/local/apache2/sites-available/"$(basename $template)".conf" > /dev/null
9+
done
10+
11+
if [[ "$NO_DEFAULT" = true ]]; then
12+
rm /usr/local/apache2/sites-available/node.template.conf
13+
rm /usr/local/apache2/sites-available/node-https.template.conf
14+
else
15+
if [[ "$WEB_SSL" = false ]]; then
16+
rm /usr/local/apache2/sites-available/node-https.template.conf
17+
fi
18+
fi
19+
20+
. /root/scripts/run-openssl.sh

0 commit comments

Comments
 (0)