问题
Months ago I deployed a Laravel app (laravel1
) using Laradock and Jwilder Nginx Proxy.
Recently I tried to deploy a second Laravel app (laravel2
), by using the same configuration values in both .env
and docker-compose.yml
files. However, I am getting the Nginx 503 error:
503 Service Temporarily Unavailable / Nginx
To give more context, this is the structure of my directories, where Laravel1
is the first app I deployed which is currently working fine, and Laravel2
which has the 503 error.
..../docker/laravel1/laradock/
..../docker/laravel2/laradock-2/
Here is part of the values from the .env
file:
#
NETWORK=webproxy
#
## HOST AND SSL variables
#
VIRTUAL_HOST=your-domain.com
LETSENCRYPT_HOST=${VIRTUAL_HOST}
LETSENCRYPT_EMAIL=your@email.com
And here go those from the docker-compose.yml
file:
version: '3'
networks:
frontend:
driver: ${NETWORKS_DRIVER}
backend:
driver: ${NETWORKS_DRIVER}
webproxy:
external:
name: "webproxy"
### NGINX Server #########################################
...
expose:
- "${NGINX_HOST_HTTP_PORT}"
- "${NGINX_HOST_HTTPS_PORT}"
#ports:
# - "${NGINX_HOST_HTTP_PORT}:80"
# - "${NGINX_HOST_HTTPS_PORT}:443"
# - "${VARNISH_BACKEND_PORT}:81"
...
networks:
- frontend
- backend
- webproxy
### Workspace Utilities ##################################
workspace:
build:
context: ./workspace
args:
- CHANGE_SOURCE=${CHANGE_SOURCE}
...
networks:
- frontend
- backend
links:
- docker-in-docker
When I list the networks with $ docker network ls
of both Laravel applications I get this list (where webproxy
is the network handled by the Nginx proxy):
webproxy
laravel1_frontend
laravel1_backend
laravel2_frontend
laravel2_backend
laravel2_default
Notice, that the Laravel 2 app has started an extra network called "laravel2_default", which I don't know where it has been set up. I can find it neither in the .env
nor docker-compose.yml
file.
When I execute docker ps
the results of the containers are (where Laravel1
is working fine, and Laravel2
has the 503 error):
Laravel1_nginx 80-81/tcp, 443/tcp
Laravel1_php-fpm 9000/tcp
Laravel1_workspace 0.0.0.0:3000-3001->3000-3001/tcp, 0.0.0.0:4200->4200/tcp, 0.0.0.0:8080->8080/tcp, 0.0.0.0:2222->22/tcp, 0.0.0.0:8001->8000/tcp
Laravel1_mysql 3306/tcp, 33060/tcp
Laravel2_nginx 80-81/tcp, 443/tcp
Laravel2_php-fpm 9000/tcp
Laravel2_workspace 0.0.0.0:2232->22/tcp, 0.0.0.0:3010->3000/tcp, 0.0.0.0:3011->3001/tcp, 0.0.0.0:4210->4200/tcp, 0.0.0.0:8091->8000/tcp, 0.0.0.0:8081->8080/tcp
Laravel2_mysql 3306/tcp, 33060/tcp
The Nginx .../nginx/sites/default.conf
file looks like
server {
listen 80;
listen [::]:80;
# For https
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;
server_name mydomain.com;
root /var/www/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.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;
}
location ~ /\.ht {
deny all;
}
#location /.well-known/acme-challenge/ {
# root /var/www/letsencrypt/;
# log_not_found off;
#}
}
I don't know if it has to do with the docker-compose.yml
file as discussed in this answer, or if there's something wrong with the Nginx default.conf
file
How do I fix this? What am I missing?
来源:https://stackoverflow.com/questions/65667557/i-get-an-nginx-503-error-when-using-laradock-to-deploy-a-laravel-app