Windows 版本:10
适用于 Windows 的 Docker:2.0.0.2 (30215)
Nginx的:最新的
Docker-compose.yml:
version: '3.7'
services:
nginx:
restart: always
image: nginx:latest
ports:
- "8000:80"
volumes:
- ./domains:/var/www
- ./modules/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./modules/nginx/sites-available:/etc/nginx/sites-available
working_dir: /var/www
Nginx.conf:
worker_processes 2;
events {
worker_connections 1024;
}
http {
access_log off;
error_log /var/log/nginx/error.log crit;
keepalive_timeout 30;
reset_timedout_connection on;
sendfile on;
tcp_nopush on;
gzip on;
gzip_proxied any;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "msie6";
include /etc/nginx/sites-available/*.conf;
}
目前我有两个虚拟主机的配置文件。
ares.测试.conf:
server {
listen 80;
listen [::]:80;
server_name ares.test www.ares.test;
root /var/www/ares.test/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
uparty.测试.conf:
server {
listen 80;
listen [::]:80;
server_name uparty.test www.uparty.test;
root /var/www/uparty.test/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
我还将以下几行添加到/etc/hosts
文件中:
127.0.0.1 ares.test
127.0.0.1 uparty.test
问题是,什么都不起作用。我的意思是,如果我http://ares.test
在浏览器的地址栏中输入,它会说找不到该页面(Forhttp://uparty.test
是相同的)。但是,如果我输入,localhost:8000
它会显示ares.test
网页内容。
我是docker和nginx的新手,所以无法独自解决这个问题。提前谢谢大家。