-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0422267
commit 62f1bbb
Showing
5 changed files
with
101 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM nginx | ||
|
||
COPY ./application.local.conf /etc/nginx/conf.d/application.local.conf | ||
|
||
WORKDIR /app | ||
|
||
VOLUME /app | ||
|
||
EXPOSE 8871 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
73 changes: 31 additions & 42 deletions
73
docker/nginx/application.local.conf → docker/nginx-child/application.local.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,31 @@ | ||
upstream php-fpm-backend { | ||
least_conn; | ||
server app1:9000; | ||
server app2:9000; | ||
server app3:9000; | ||
} | ||
|
||
server { | ||
# указываем 80 порт для соединения | ||
listen 80; | ||
# нужно указать, какому доменному имени принадлежит наш конфиг | ||
server_name application.local; | ||
|
||
# задаём корневую директорию | ||
root /app; | ||
|
||
# стартовый файл | ||
index index.php index.html; | ||
|
||
# при обращении к статическим файлам логи не нужны, равно как и обращение к fpm | ||
# http://application.local/static/some.png | ||
location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ { | ||
access_log off; | ||
expires max; | ||
} | ||
|
||
# помним про единую точку доступа | ||
# все запросы заворачиваются в корневую директорию root на index.php | ||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
# и наконец правило обращения к php-fpm | ||
location ~* .php$ { | ||
try_files $uri = 404; | ||
fastcgi_split_path_info ^(.+.php)(/.+)$; | ||
fastcgi_pass php-fpm-backend; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
} | ||
upstream backend { | ||
server app1:9000; | ||
server app2:9000; | ||
server app3:9000; | ||
} | ||
|
||
server { | ||
# указываем 80 порт для соединения | ||
listen 8871; | ||
# нужно указать, какому доменному имени принадлежит наш конфиг | ||
|
||
# задаём корневую директорию | ||
root /app; | ||
|
||
# стартовый файл | ||
index index.php index.html; | ||
|
||
# помним про единую точку доступа | ||
# все запросы заворачиваются в корневую директорию root на index.php | ||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
# и наконец правило обращения к php-fpm | ||
location ~* .php$ { | ||
fastcgi_pass backend; | ||
|
||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
upstream nginx-balancer{ | ||
server nginx-child-1:8871; | ||
server nginx-child-2:8871; | ||
server nginx-child-3:8871; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name application.local; | ||
|
||
location / { | ||
proxy_pass http://nginx-balancer; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Scheme $scheme; | ||
} | ||
} |