Hi,
I’m trying to create a new stack of containers Nginx, php, mysql and wordpress.
For now I just have nginx alone and I’m trying to set a local hostname to avoid the classic localhost:80 for futur SSL certificate tests.
So instead of having localhost:80 when I run Nginx, I would like to have “myapp.local”
I created an .env file with a constant HOSTANE=myapp.local
My docker-compose.yml file is like that:
services:
nginx:
container_name: ${CONTAINER_NAME}-nginx
image: nginx:1.27.3-alpine
restart: unless-stopped
env_file: .env
environment:
HOSTNAME: ${HOSTNAME}
ports:
- 80:80
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
- internal
I created a default.conf file for nginx configuration and added:
server_name ${HOSTNAME};
I saw 2 different ways to setup environment variable…once it is called NGINX_HOST and once it’s HOSTNAME
so I tried both way:
environment:
HOSTNAME: ${HOSTNAME}
and
environment:
NGINX_HOST=${HOSTNAME}
but when my container runs it’s always localhost:80
any idea what I missed ?
thx