Skip to content

Commit 93504a7

Browse files
committed
Proof of concept - LaraDock hosting multiple sites
1 parent 28b4077 commit 93504a7

7 files changed

Lines changed: 73 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea
12
/logs
23
/data
3-
.env
4+
.env

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ services:
203203
volumes:
204204
- ../:/var/www/laravel
205205

206+
# By default, site_a and site_b are mirroring the parent Laravel app.
207+
# This is because the nginx container has these domains
208+
# enabled to demonstrate how to support multiple sites
209+
- ../:/var/www/site_a
210+
- ../:/var/www/site_b
211+
212+
# This demonstrates example of where you may mount sites
213+
# - ../../site_a/:/var/www/site_a
214+
# - ../../site_b/:/var/www/site_b
215+
216+
206217
### Databases Data Container ################################
207218

208219
volumes_data:

nginx/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM nginx:alpine
33
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
44

55
ADD nginx.conf /etc/nginx/
6-
ADD laravel.conf /etc/nginx/conf.d/laravel.conf
6+
COPY sites/*.conf /etc/nginx/sites-available/
77

88
ARG PHP_UPSTREAM=php-fpm
99

nginx/nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ http {
2424
gzip on;
2525
gzip_disable "msie6";
2626
include /etc/nginx/conf.d/*.conf;
27+
include /etc/nginx/sites-available/*;
2728
open_file_cache max=100;
2829
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
server {
2+
23
listen 80 default_server;
34
listen [::]:80 default_server ipv6only=on;
45

6+
server_name laravel;
57
root /var/www/laravel/public;
68
index index.php index.html index.htm;
79

nginx/sites/site_a.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
server {
2+
3+
listen 80;
4+
listen [::]:80;
5+
6+
server_name site_a;
7+
root /var/www/site_a/public;
8+
index index.php index.html index.htm;
9+
10+
location / {
11+
try_files $uri $uri/ /index.php$is_args$args;
12+
}
13+
14+
location ~ \.php$ {
15+
try_files $uri /index.php =404;
16+
fastcgi_pass php-upstream;
17+
fastcgi_index index.php;
18+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
19+
include fastcgi_params;
20+
}
21+
22+
location ~ /\.ht {
23+
deny all;
24+
}
25+
}
26+
27+
28+

nginx/sites/site_b.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
server {
2+
3+
listen 80;
4+
listen [::]:80;
5+
6+
server_name site_b;
7+
root /var/www/site_b/public;
8+
index index.php index.html index.htm;
9+
10+
location / {
11+
try_files $uri $uri/ /index.php$is_args$args;
12+
}
13+
14+
location ~ \.php$ {
15+
try_files $uri /index.php =404;
16+
fastcgi_pass php-upstream;
17+
fastcgi_index index.php;
18+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
19+
include fastcgi_params;
20+
}
21+
22+
location ~ /\.ht {
23+
deny all;
24+
}
25+
}
26+
27+
28+

0 commit comments

Comments
 (0)