I am trying to access my symfony application via a docker compose setup
I have issues with nginx default.conf
When trying to access the app I am getting bad gateway
docker logs show an error:
no resolver defined to resolve app, client: 193.32.126.216
so I tried putting 127.0.0.1:9000
instead of app:9000
and I get a new error:
connect() failed (111: Connection refused) while connecting to upstream
I have this configuration:
version: "3"
services:
nginx:
container_name: nginx
image: "${NGINX_IMAGE}"
build: build/nginx
restart: always
env_file: .env
ports:
# - "8000:443"
- "80:80"
- "443:443"
volumes:
- "${APP_HOST_DIR}/public:/var/www/app/public:ro"
- "${APP_HOST_LETSENCRYPT}:${APP_CONTAINER_LETSENCRYPT}"
- "${APP_HOST_NGINX_CONF}:${APP_CONTAINER_NGINX_CONF}"
volumes_from:
- app
networks:
- central_mr
depends_on:
- app
app:
container_name: app
image: "${APP_IMAGE}"
restart: always
build: build/app
env_file: .env
networks:
- central_mr
volumes:
- "${APP_HOST_DIR}:${APP_CONTAINER_DIR}"
networks:
central_mr:
.env
# PROD
MODE=prod
# IMAGES
NGINX_IMAGE=mr/nginx:prod
MARIADB_VERSION=latest
APP_IMAGE=mr/app:prod
# APP
APP_HOST_DIR=./app
APP_CONTAINER_DIR=/var/www/app/
# MARIADB
MARIADB_DATA_DIR=/var/lib/mysql
MARIADB_LOG_DIR=/var/logs/mysql
SQL_INIT=./build/database/prod
MYSQL_DATABASE=app
MYSQL_USER=app
MYSQL_PASSWORD=password
MYSQL_ROOT_PASSWORD=password
APP_HOST_NGINX_CONF=./volume/etc/nginx/prod/default.conf
APP_CONTAINER_NGINX_CONF=/etc/nginx/conf.d/default.conf
# NGINX
APP_HOST_NGINX_CONF=./volume/etc/nginx/prod/default.conf
APP_CONTAINER_NGINX_CONF=/etc/nginx/conf.d/default.conf
# SSL
APP_HOST_LETSENCRYPT=/etc/letsencrypt/
APP_CONTAINER_LETSENCRYPT=/etc/letsencrypt/
default.conf
server {
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /var/www/app/public/;
index index.php;
server_name mywebsite.com;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
set $upstream app:9000;
fastcgi_pass $upstream;
fastcgi_index index.php;
}
}
fd