I try to use docker to run my server in local and use dnsmasq to able to receive requests from others devices in the local network.
But it does not work.
Is there anything wrong?
These are my project:
network/
├── nginx/
│ ├── sample.d/
│ │ └── sample.conf
│ └── nginx.conf
├── sample_server/
│ ├── Dockerfile
│ ├── api.py
│ └── requirements.txt
├── dnsmasq/
│ └── dnsmasq.conf
└── docker-compose.yml
dnsmasq.conf:
log-queries
no-resolv
strict-order
server=1.0.0.1
server=1.1.1.1
server=/demo.me/127.0.0.1
address=/demo.me/192.168.2.31
nginx.conf:
# user www www; ## Default: nobody
worker_processes 1; ## Default: 1
# error_log logs/error.log;
# pid logs/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
http {
index index.html index.htm index.php;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
upstream big_server_com {
server 127.0.0.3:8000 weight=5;
server 127.0.0.3:8001 weight=5;
server 192.168.0.1:8000;
server 192.168.0.1:8001;
}
include sample.d/*;
}
sample.conf:
server {
listen 80;
server_name demo.me;
location / {
proxy_set_header Host $host;
proxy_pass http://sampleserver:5000;
}
}
docker_compose.yml:
networks:
test-network:
external: true
services:
nginx:
restart: always
container_name: sample_nginx
image: nginx
networks:
- test-network
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/sample.d:/etc/nginx/conf.d
depends_on:
- sampleserver
dns:
container_name: dnsmasq
restart: always
image: dockurr/dnsmasq
volumes:
- ./dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf
ports:
- 53:53/tcp
- 53:53/udp
cap_add:
- NET_ADMIN
networks:
- test-network
sampleserver:
container_name: sample_server
image: be-flask-python-3-12:1.0.0
volumes:
- ./sample_server/:/app/
networks:
- test-network
command:
- api.py
I also added “127.0.0.1 demo.me” to /etc/hosts but I still can not receive request http://demo.me/ from another device in the local network.