Skip to content

Commit 5c0b831

Browse files
committed
make the PHP_UPSTREAM config for NGINX and Apache identical
1 parent 004e435 commit 5c0b831

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

apache2/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ FROM webdevops/apache:ubuntu-16.04
22

33
MAINTAINER Eric Pfeiffer <computerfr33k@users.noreply.github.com>
44

5-
ARG PHP_SOCKET=php-fpm:9000
5+
ARG PHP_UPSTREAM_CONTAINER=php-fpm
6+
ARG PHP_UPSTREAM_PORT=9000
67

7-
ENV WEB_PHP_SOCKET=$PHP_SOCKET
8+
ENV WEB_PHP_SOCKET=${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}
89

910
ENV WEB_DOCUMENT_ROOT=/var/www/public/
1011

docker-compose.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ services:
107107
networks:
108108
- backend
109109

110-
### Nginx Server Container ##################################
110+
### NGINX Server Container ##################################
111111

112112
nginx:
113113
build:
114114
context: ./nginx
115115
args:
116-
- PHP_UPSTREAM=php-fpm
116+
- PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER}
117+
- PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT}
117118
volumes_from:
118119
- applications
119120
volumes:
@@ -146,7 +147,8 @@ services:
146147
build:
147148
context: ./apache2
148149
args:
149-
- PHP_SOCKET=${PHP_SOCKET}
150+
- PHP_UPSTREAM_CONTAINER=${APACHE_PHP_UPSTREAM_CONTAINER}
151+
- PHP_UPSTREAM_PORT=${APACHE_PHP_UPSTREAM_PORT}
150152
volumes_from:
151153
- applications
152154
volumes:

env-example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ NGINX_HOST_HTTP_PORT=80
8080
NGINX_HOST_HTTPS_PORT=443
8181
NGINX_HOST_LOG_PATH=./logs/nginx/
8282
NGINX_SITES_PATH=./nginx/sites/
83+
NGINX_PHP_UPSTREAM_CONTAINER=php-fpm
84+
NGINX_PHP_UPSTREAM_PORT=9000
8385

8486
### APACHE #############################################################################################################
8587

8688
APACHE_HOST_HTTP_PORT=80
8789
APACHE_HOST_HTTPS_PORT=443
88-
APACHE2_PHP_SOCKET=php-fpm:9000
8990
APACHE_HOST_LOG_PATH=./logs/apache2
9091
APACHE_SITES_PATH=./apache2/sites
91-
PHP_SOCKET=php-fpm:9000
92+
APACHE_PHP_UPSTREAM_CONTAINER=php-fpm
93+
APACHE_PHP_UPSTREAM_PORT=9000
9294

9395
### MYSQL ##############################################################################################################
9496

nginx/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
44

55
ADD nginx.conf /etc/nginx/
66

7-
ARG PHP_UPSTREAM=php-fpm
7+
ARG PHP_UPSTREAM_CONTAINER=php-fpm
8+
ARG PHP_UPSTREAM_PORT=9000
89

910
# fix a problem--#397, change application source from dl-cdn.alpinelinux.org to aliyun source.
1011
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories
1112

1213
RUN apk update \
1314
&& apk upgrade \
1415
&& apk add --no-cache bash \
15-
&& adduser -D -H -u 1000 -s /bin/bash www-data \
16-
&& rm /etc/nginx/conf.d/default.conf \
17-
&& echo "upstream php-upstream { server ${PHP_UPSTREAM}:9000; }" > /etc/nginx/conf.d/upstream.conf
16+
&& adduser -D -H -u 1000 -s /bin/bash www-data
17+
18+
# Set upstream conf and remove the default conf
19+
RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
20+
&& rm /etc/nginx/conf.d/default.conf
1821

1922
CMD ["nginx"]
2023

0 commit comments

Comments
 (0)