Skip to content

Commit e1a4a8e

Browse files
authored
Added HTTP support (#42)
1 parent cfe8129 commit e1a4a8e

9 files changed

Lines changed: 264 additions & 23 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ docker run --rm -p 5000:5000 --name registry registry:2
2424
```
2525
This will create a temporary local registry that we can now use for testing Dockerfiles locally, for example:
2626
```Dockerfile
27-
FROM localhost:5000/php:8.0-cli
27+
FROM localhost:5000/php:8.1-cli
2828

2929
CMD php -v
3030
```
3131

32-
I can also inspect the image by running
32+
To do this, all I need to run is the `dev.sh` on my machine to run a build of all images for my local machine.
33+
34+
#### Inspect images
35+
This is helpful for inspecting images:
36+
```sh
37+
docker run --rm -it localhost:5000/php:8.1-cli bash
38+
```
39+
40+
#### Running a test web server:
41+
This is helpful for testing things out:
3342
```sh
34-
docker run --rm -it localhost:5000/php:8.0-cli bash
43+
docker run --rm -v $(pwd):/var/www/html -p 80:80 -p 443:443 localhost:5000/php:8.1-fpm-nginx
3544
```

‎generated-dockerfiles/7.4/fpm-apache/etc/apache2/sites-available/000-default.conf‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,40 @@
66
# Set CloudFlare Real IP
77
RemoteIPHeader CF-Connecting-IP
88

9-
# Redirect all HTTP traffic to HTTPS
10-
RewriteEngine On
11-
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
9+
# Configure main document root
10+
DocumentRoot ${APACHE_DOCUMENT_ROOT}
11+
12+
# Set basic settings for document root. Configure correct directory indexes and disable directory browsing
13+
<Directory ${APACHE_DOCUMENT_ROOT}>
14+
AllowOverride All
15+
Require all granted
16+
Options -Indexes +FollowSymLinks +MultiViews
17+
DirectoryIndex index.php index.html index.htm
18+
</Directory>
19+
20+
# Healthchecks: Set /ping to be the healhcheck URL
21+
ProxyPass "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
22+
ProxyPassReverse "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
23+
24+
# For any files that match PHP, pass it to PHP-FPM for processing
25+
<FilesMatch "\.php$">
26+
# 2.4.10+ can proxy to unix socket
27+
ProxyFCGIBackendType GENERIC
28+
SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
29+
</FilesMatch>
30+
31+
# Set the Proxy Timeout to be 30 minutes
32+
ProxyTimeout 1800
1233

1334
# Configure Log Settings
1435
LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost
1536
ErrorLog /dev/stderr
1637
TransferLog /dev/stdout
1738
LogLevel error
1839

40+
# Disable Server Signature for increased security
41+
ServerSignature Off
42+
1943
</VirtualHost>
2044

2145
<VirtualHost *:443>

‎generated-dockerfiles/7.4/fpm-nginx/etc/nginx/sites-available/default‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,44 @@ server {
44
listen 80 default_server;
55
listen [::]:80 default_server;
66

7+
root /var/www/html/public;
8+
9+
# Set allowed "index" files
10+
index index.html index.htm index.php;
11+
712
server_name _;
813

9-
# Redirect all HTTP traffic to HTTPS
10-
return 301 https://$host$request_uri;
14+
charset utf-8;
15+
16+
# Set max upload to 2048M
17+
client_max_body_size 2048M;
18+
19+
# Healthchecks: Set /ping to be the healhcheck URL
20+
location /ping {
21+
access_log off;
22+
23+
# set max 5 seconds for healthcheck
24+
fastcgi_read_timeout 5s;
25+
26+
include fastcgi_params;
27+
fastcgi_param SCRIPT_NAME /ping;
28+
fastcgi_param SCRIPT_FILENAME /ping;
29+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
30+
}
31+
32+
# Have NGINX try searching for PHP files as well
33+
location / {
34+
try_files $uri $uri/ /index.php?$query_string;
35+
}
36+
37+
# Pass "*.php" files to PHP-FPM
38+
location ~ \.php$ {
39+
include snippets/fastcgi-php.conf;
40+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
41+
}
42+
43+
# additional config
44+
include /etc/nginx/server-opts.d/*.conf;
1145
}
1246

1347
# HTTPS Configuration

‎generated-dockerfiles/8.0/fpm-apache/etc/apache2/sites-available/000-default.conf‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,40 @@
66
# Set CloudFlare Real IP
77
RemoteIPHeader CF-Connecting-IP
88

9-
# Redirect all HTTP traffic to HTTPS
10-
RewriteEngine On
11-
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
9+
# Configure main document root
10+
DocumentRoot ${APACHE_DOCUMENT_ROOT}
11+
12+
# Set basic settings for document root. Configure correct directory indexes and disable directory browsing
13+
<Directory ${APACHE_DOCUMENT_ROOT}>
14+
AllowOverride All
15+
Require all granted
16+
Options -Indexes +FollowSymLinks +MultiViews
17+
DirectoryIndex index.php index.html index.htm
18+
</Directory>
19+
20+
# Healthchecks: Set /ping to be the healhcheck URL
21+
ProxyPass "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
22+
ProxyPassReverse "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
23+
24+
# For any files that match PHP, pass it to PHP-FPM for processing
25+
<FilesMatch "\.php$">
26+
# 2.4.10+ can proxy to unix socket
27+
ProxyFCGIBackendType GENERIC
28+
SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
29+
</FilesMatch>
30+
31+
# Set the Proxy Timeout to be 30 minutes
32+
ProxyTimeout 1800
1233

1334
# Configure Log Settings
1435
LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost
1536
ErrorLog /dev/stderr
1637
TransferLog /dev/stdout
1738
LogLevel error
1839

40+
# Disable Server Signature for increased security
41+
ServerSignature Off
42+
1943
</VirtualHost>
2044

2145
<VirtualHost *:443>

‎generated-dockerfiles/8.0/fpm-nginx/etc/nginx/sites-available/default‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,44 @@ server {
44
listen 80 default_server;
55
listen [::]:80 default_server;
66

7+
root /var/www/html/public;
8+
9+
# Set allowed "index" files
10+
index index.html index.htm index.php;
11+
712
server_name _;
813

9-
# Redirect all HTTP traffic to HTTPS
10-
return 301 https://$host$request_uri;
14+
charset utf-8;
15+
16+
# Set max upload to 2048M
17+
client_max_body_size 2048M;
18+
19+
# Healthchecks: Set /ping to be the healhcheck URL
20+
location /ping {
21+
access_log off;
22+
23+
# set max 5 seconds for healthcheck
24+
fastcgi_read_timeout 5s;
25+
26+
include fastcgi_params;
27+
fastcgi_param SCRIPT_NAME /ping;
28+
fastcgi_param SCRIPT_FILENAME /ping;
29+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
30+
}
31+
32+
# Have NGINX try searching for PHP files as well
33+
location / {
34+
try_files $uri $uri/ /index.php?$query_string;
35+
}
36+
37+
# Pass "*.php" files to PHP-FPM
38+
location ~ \.php$ {
39+
include snippets/fastcgi-php.conf;
40+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
41+
}
42+
43+
# additional config
44+
include /etc/nginx/server-opts.d/*.conf;
1145
}
1246

1347
# HTTPS Configuration

‎generated-dockerfiles/8.1/fpm-apache/etc/apache2/sites-available/000-default.conf‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,40 @@
66
# Set CloudFlare Real IP
77
RemoteIPHeader CF-Connecting-IP
88

9-
# Redirect all HTTP traffic to HTTPS
10-
RewriteEngine On
11-
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
9+
# Configure main document root
10+
DocumentRoot ${APACHE_DOCUMENT_ROOT}
11+
12+
# Set basic settings for document root. Configure correct directory indexes and disable directory browsing
13+
<Directory ${APACHE_DOCUMENT_ROOT}>
14+
AllowOverride All
15+
Require all granted
16+
Options -Indexes +FollowSymLinks +MultiViews
17+
DirectoryIndex index.php index.html index.htm
18+
</Directory>
19+
20+
# Healthchecks: Set /ping to be the healhcheck URL
21+
ProxyPass "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
22+
ProxyPassReverse "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
23+
24+
# For any files that match PHP, pass it to PHP-FPM for processing
25+
<FilesMatch "\.php$">
26+
# 2.4.10+ can proxy to unix socket
27+
ProxyFCGIBackendType GENERIC
28+
SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
29+
</FilesMatch>
30+
31+
# Set the Proxy Timeout to be 30 minutes
32+
ProxyTimeout 1800
1233

1334
# Configure Log Settings
1435
LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost
1536
ErrorLog /dev/stderr
1637
TransferLog /dev/stdout
1738
LogLevel error
1839

40+
# Disable Server Signature for increased security
41+
ServerSignature Off
42+
1943
</VirtualHost>
2044

2145
<VirtualHost *:443>

‎generated-dockerfiles/8.1/fpm-nginx/etc/nginx/sites-available/default‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,44 @@ server {
44
listen 80 default_server;
55
listen [::]:80 default_server;
66

7+
root /var/www/html/public;
8+
9+
# Set allowed "index" files
10+
index index.html index.htm index.php;
11+
712
server_name _;
813

9-
# Redirect all HTTP traffic to HTTPS
10-
return 301 https://$host$request_uri;
14+
charset utf-8;
15+
16+
# Set max upload to 2048M
17+
client_max_body_size 2048M;
18+
19+
# Healthchecks: Set /ping to be the healhcheck URL
20+
location /ping {
21+
access_log off;
22+
23+
# set max 5 seconds for healthcheck
24+
fastcgi_read_timeout 5s;
25+
26+
include fastcgi_params;
27+
fastcgi_param SCRIPT_NAME /ping;
28+
fastcgi_param SCRIPT_FILENAME /ping;
29+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
30+
}
31+
32+
# Have NGINX try searching for PHP files as well
33+
location / {
34+
try_files $uri $uri/ /index.php?$query_string;
35+
}
36+
37+
# Pass "*.php" files to PHP-FPM
38+
location ~ \.php$ {
39+
include snippets/fastcgi-php.conf;
40+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
41+
}
42+
43+
# additional config
44+
include /etc/nginx/server-opts.d/*.conf;
1145
}
1246

1347
# HTTPS Configuration

‎templates/fpm-apache/etc/apache2/sites-available/000-default.conf‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,40 @@
66
# Set CloudFlare Real IP
77
RemoteIPHeader CF-Connecting-IP
88

9-
# Redirect all HTTP traffic to HTTPS
10-
RewriteEngine On
11-
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
9+
# Configure main document root
10+
DocumentRoot ${APACHE_DOCUMENT_ROOT}
11+
12+
# Set basic settings for document root. Configure correct directory indexes and disable directory browsing
13+
<Directory ${APACHE_DOCUMENT_ROOT}>
14+
AllowOverride All
15+
Require all granted
16+
Options -Indexes +FollowSymLinks +MultiViews
17+
DirectoryIndex index.php index.html index.htm
18+
</Directory>
19+
20+
# Healthchecks: Set /ping to be the healhcheck URL
21+
ProxyPass "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
22+
ProxyPassReverse "/ping" "unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
23+
24+
# For any files that match PHP, pass it to PHP-FPM for processing
25+
<FilesMatch "\.php$">
26+
# 2.4.10+ can proxy to unix socket
27+
ProxyFCGIBackendType GENERIC
28+
SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/"
29+
</FilesMatch>
30+
31+
# Set the Proxy Timeout to be 30 minutes
32+
ProxyTimeout 1800
1233

1334
# Configure Log Settings
1435
LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost
1536
ErrorLog /dev/stderr
1637
TransferLog /dev/stdout
1738
LogLevel error
1839

40+
# Disable Server Signature for increased security
41+
ServerSignature Off
42+
1943
</VirtualHost>
2044

2145
<VirtualHost *:443>

‎templates/fpm-nginx/etc/nginx/sites-available/default‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,44 @@ server {
44
listen 80 default_server;
55
listen [::]:80 default_server;
66

7+
root /var/www/html/public;
8+
9+
# Set allowed "index" files
10+
index index.html index.htm index.php;
11+
712
server_name _;
813

9-
# Redirect all HTTP traffic to HTTPS
10-
return 301 https://$host$request_uri;
14+
charset utf-8;
15+
16+
# Set max upload to 2048M
17+
client_max_body_size 2048M;
18+
19+
# Healthchecks: Set /ping to be the healhcheck URL
20+
location /ping {
21+
access_log off;
22+
23+
# set max 5 seconds for healthcheck
24+
fastcgi_read_timeout 5s;
25+
26+
include fastcgi_params;
27+
fastcgi_param SCRIPT_NAME /ping;
28+
fastcgi_param SCRIPT_FILENAME /ping;
29+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
30+
}
31+
32+
# Have NGINX try searching for PHP files as well
33+
location / {
34+
try_files $uri $uri/ /index.php?$query_string;
35+
}
36+
37+
# Pass "*.php" files to PHP-FPM
38+
location ~ \.php$ {
39+
include snippets/fastcgi-php.conf;
40+
fastcgi_pass unix:/var/run/php/php-fpm.sock;
41+
}
42+
43+
# additional config
44+
include /etc/nginx/server-opts.d/*.conf;
1145
}
1246

1347
# HTTPS Configuration

0 commit comments

Comments
 (0)