Answer the question
In order to leave comments, you need to log in
What's wrong with setting up a site in docker?
my docker starter project contains three small
docker-compose.yml files
version: '3'
services:
web:
image: nginx:1.15
ports:
- 8888:80
volumes:
- ./conf/doc.loc:/etc/nginx/sites-enabled/doc.loc
- .:/app
server {
listen 80;
server_name doc.loc;
index index.html index.php;
root /app/public;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
try_files $uri $uri/ =404;
}
}
<h3>HELLO, WORLD</h3>
Answer the question
In order to leave comments, you need to log in
That's right, you have a site opened on localhost, which corresponds to the default config with server_name _;
, server_name doc.loc
that is, if you access doc.loc:8888 after writing the "127.0.0.1 doc.loc" file in hosts, then it will open what you asked.
If you need it to work only on localhost, then just overwrite the default config:
...
volumes:
- ./conf/doc.loc:/etc/nginx/sites-enabled/default
...
version: '3'
services:
web:
image: nginx:1.15
ports:
- 8888:80
volumes:
- ./conf/doc.loc:/etc/nginx/sites-enabled/default
- .:/app
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
index index.html index.php;
root /app/public;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
try_files $uri $uri/ =404;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question