[HELP] CONFIGURATION DE LARAVEL DOCKER NGINX l'url ne change pas

OP
I3

iso3god

il y a 4 mois

Bonjour à tous. Je suis nouveau sur Docker. J'ai un problème avec la configuration d'un projet Laravel avec Docker.
Je voudrais changer l'url qui est affichée dans le navigateur. Mais je n'y arrive pas.
J'ai modifié l'entrée APP_URL dans le fichier .env de Laravel, mais le serveur Nginx n'applique pas la modification.

Ma question est la suivante : comment puis-je appliquer le changement ?

Voici mes 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