Answer the question
In order to leave comments, you need to log in
How to setup NGNIX+Docker-compose with subdomains?
You need to configure nginx to work with subdomains so that each subdomain sends to its own container. Now for tests I use the old domain, which is configured (records) for my ip. NGINX is installed in a separate compose container, the settings are as follows:
nginx.conf:
server {
listen 80;
server_name phpmyadmin.example.com www.phpmyadmin.example.com;
location / {
resolver 127.0.0.11;
set $project http://phpmyadmin:80;
proxy_pass $project;
}
}
server {
listen 80;
server_name bob.example.com www.bob.example.com;
location / {
resolver 127.0.0.11;
set $project http://bob:80;
proxy_pass $project;
}
}
version: '3.7'
services:
nginx:
container_name: nginx
build: .
networks:
nginx_net:
volumes:
- ./data/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- 80:80
networks:
nginx_net:
name: nginx_net
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question