Hello everyone. I’m new to Docker. I have a problem with the configuration of a Laravel project with Docker.
I would like to change the url that is displayed in the browser. But I can’t.
I’ve modified the APP_URL entry in the Laravel .env file, but the Nginx server doesn’t apply the modification.
My question is, how do I apply the change?
here are my configurations:
******************************************* start
************ compose.yaml
services:
nginx:
build:
context: .
dockerfile: nginx.dockerfile
container_name: nginx
depends_on:
- php
- mysql
ports:
- 80:80
- 443:443
volumes:
- ./src:/var/www/html
networks:
- laravel
php:
build:
context: .
dockerfile: php.dockerfile
container_name: php
volumes:
- ./src:/var/www/html
networks:
- laravel
mysql:
image: mysql:9.1.0
container_name: mysql
ports:
- 3306:3306
environment:
MYSQL_DATABASE: laraveldb
MYSQL_USER: laravel
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
volumes:
- ./mysql:/var/lib/mysql
networks:
- laravel
composer:
image: composer:latest
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
networks:
- laravel
networks:
laravel:
name: laravel
*************** default.conf (nginx):
server {
listen 80;
listen [::]:80;
server_name localhost;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php index.html index.htm;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ ^/index\.php(/|$) {
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
****************** nginx.dockerfile:
FROM nginx:stable-alpine
ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf
RUN mkdir -p /var/www/html
****************** php.dockerfile:
FROM php:8.2.27-fpm-alpine
RUN mkdir -p /var/www/html
RUN apk --no-cache add shadow && usermod -u 1000 www-data
RUN docker-php-ext-install pdo pdo_mysql
*************** .env:
APP_NAME="My php website"
APP_ENV=local
APP_KEY=base64:N2vUzwN/DT2/P5zwX9/wiEzaYNtCGyURU7UX24oavcE=
APP_DEBUG=true
APP_TIMEZONE=Europe/Paris
APP_URL=http://mponanwess.test
********************************************** end
Thanks for your help