我第一次使用Docker,试图构建NGINX代理(也是第一次使用NGINX)。我看过多个指南,似乎都暗示我走了正确的路,但是运行图像时,我得到了duplicate listen options for [::]:80 in /etc/nginx/conf.d/site.conf
。
site.conf:
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name gamersplane.local;
root /var/www;
index dispatch.php;
location / {
try_files $uri /dispatch.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /dispatch.php =404;
fastcgi_pass api:9000;
fastcgi_index dispatch.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
}
api.conf:
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name api.gamersplane.local;
root /var/www/api;
index dispatch.php;
location / {
try_files $uri /dispatch.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /dispatch.php =404;
fastcgi_pass api:9000;
fastcgi_index dispatch.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
}
我有两个撰写文件:
docker-compose.yal
proxy:
build:
context: ./nginx
dockerfile: Dockerfile
container_name: gamersplane-proxy
ports:
- 80:80
volumes:
- ../:/var/www
docker-compose.dev.yml
proxy:
volumes:
- ./nginx/dev/site.conf:/etc/nginx/conf.d/site.conf
- ./nginx/dev/api.conf:/etc/nginx/conf.d/api.conf