Hi there,
We are building a multi-lingual website using docker compose. Each regional website has its own domain, e.g. .co.uk, .com.au, .co.nz etc. I want to test this with my docker compose setup. Here’s what I have:
services:
nginx:
image: nginx:stable-alpine
ports:
- "8000:80"
volumes:
- "./source-code:/srv"
- "./nginx/conf.d:/etc/nginx/conf.d"
links:
- mysql
- php
php:
image: php-alpine
volumes:
- "./source-code:/srv"
mysql:
image: mysql:5.6
volumes:
- "mysql_data:/var/lib/mysql"
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
ports:
- "5000:3306"
This site works fine if you access the site via localhost:8000
, however, I do want to test multi domains before I get real DNS records for live domains. I tried editing my nginx conf to be like following:
server {
listen 80;
server_name site.co.uk;
root /srv/public/en_gb;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
server {
listen 80;
server_name site.com.au;`
root /srv/public/en_au;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
And added host entries into my /etc/hosts
file.
...
127.0.0.1 site.co.uk site.com.au
It seems that it only picks up the second server block, which is en_au
one. Does anyone have any idea how I can approach this?
Thanks in advance!