Problème d'affichage depuis changement URL

Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Nombre de réponses : 11

Bonjour à tous,

Voici la configuration :

Os : Debian 10
PHP : 7.4
Ngnx : nginx version: nginx/1.20.1
MariaBD : 10.3.27-MariaDB-0+deb10u1
Haproxy
Moodle version : Dernière version
Thème : Edumy

J'avais installé Moodle avec un adresse IP  en 192.168.1.14 en attendant d'avoir accès à notre domaine.
Maintenant j'ai accès au domaine donc j'ai voulu faire la migration grâce à http://192.168.1.14/admin/tool/replace/index.php.

J'ai ajouté dans Ngnx :

       server_name formation.domaine.fr;

et dans /var/www/moodle :

$CFG->wwwroot   = 'http://formation.domaine.fr'; au lieu de $CFG->wwwroot   = 'http://192.168.1.14';

Avec l'adresse IP Moodle s'affichage bien. Mais dès que je mets le domaine 

Voici l'affichage avec l'adresse IP


Voici l'affichage avec le domaine


Comment puis résoudre ce problème d'affichage ?

Merci beaucoup
Bien cordialement,

Alain

Moyenne des évaluations  -
En réponse à Alain Dos Reis Pasquault

Re: Problème d'affichage depuis changement URL

par Nicolas Martignoni,
Avatar Développeurs Avatar Développeurs de plugins Avatar Documentation writers Avatar Moodleurs particulièrement utiles Avatar Testeurs Avatar Traducteurs

Bonjour,

Un changement d'URL constitue une migration de l'instance. Il s'agit donc d'effectuer toutes les étapes nécessaire à cette migration. Voyez la documentation.

Moyenne des évaluations Utile (1)
En réponse à Nicolas Martignoni

Re: Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Bonjour,

J'ai bien suivi les instructions de la migration.
J'ai essayé d'installer un autre Moodle avec le domaine et j'ai le même problème d'affichage.
Au niveau de Ngnix, existe-t-il un exemple de configuration dans site-available pour moodle ?

Je vous joins mon fichier.
Qu'en pensez-vous ? Que conseillez-vous ?

Merci

Bien cordialement

Alain
En réponse à Alain Dos Reis Pasquault

Re: Problème d'affichage depuis changement URL

par Patrick Lemaire,
Avatar Développeurs de plugins Avatar Documentation writers Avatar Moodleurs particulièrement utiles Avatar Testeurs Avatar Traducteurs
Bonjour Alain,
Bienvenue dans notre communauté 😊
Plusieurs remarques :
a) Lorsque tu utilises l'adresse IP, c'est le serveur local qui te répond (192.168.1.14) et lorsque tu utilises le nom de domaine, c'est le serveur distant (peut-être la même machine en fonction de ta configuration réseau que je ne connais pas).
b) Je remarque une redirection http->httpS sur la seconde capture (peut-être une redirection automatique via Nginx ?) ! Donc déjà, dans ton fichier config.php, il faut indiquer :
$CFG->wwwroot   = 'https://formation.domaine.fr';

À bientôt,
Patrick
Moyenne des évaluations Utile (1)
En réponse à Alain Dos Reis Pasquault

Re: Problème d'affichage depuis changement URL

par Nicolas Martignoni,
Avatar Développeurs Avatar Développeurs de plugins Avatar Documentation writers Avatar Moodleurs particulièrement utiles Avatar Testeurs Avatar Traducteurs

Voici un exemple (en production) de configuration Nginx pour Moodle, sur Debian Buster.

Moyenne des évaluations Utile (1)
En réponse à Nicolas Martignoni

Re: Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Bonjour Nicolas,

Merci pour le fichier.
Je vais le mettre pour mon domaine.
Je reviens vers vous pour vous dire si ça fonctionne bien.

Merci

Alain
En réponse à Nicolas Martignoni

Re: Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Bonjour Nicolas,

J'ai mis votre fichier nginx maintenant j'ai une erreur 503.

Avez-vous une idée ?

Merci
cordialement,
Alain
En réponse à Alain Dos Reis Pasquault

Re: Problème d'affichage depuis changement URL

par Nicolas Martignoni,
Avatar Développeurs Avatar Développeurs de plugins Avatar Documentation writers Avatar Moodleurs particulièrement utiles Avatar Testeurs Avatar Traducteurs

Tout ça dépend de l'installation et de la configuration de Nginx sur votre serveur: voyez avec l'administrateur système du serveur.

Moyenne des évaluations Utile (1)
En réponse à Nicolas Martignoni

Re: Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Bonjour Nicolas,
J'ai installé un serveur HaProxy, j'ai fait un certificat wildcard pour le domaine.
Donc je pense que ça vient de HaProxy.
Je vous tiens informer et je vous donnerai la config de HaProxy pour la communauté.

Merci
Cordialement
Alain
En réponse à Nicolas Martignoni

Re: Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Bonjour Nicolas,
En fait, j'ai suivi votre fichier.
Je l'ai complété. Je n'ai plus d'erreur 503.
J'ai essayé en direct sans HAProxy.

Maintenant je suis bien en https.

Je vois le site mais le thème ne s'affiche pas.



Voici mon fichier config de Moodle,

<?php  // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype    = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 't';
$CFG->dbuser    = 't';
$CFG->dbpass    = 'T';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
  'dbcollation' => 'utf8mb4_unicode_ci',
);
$CFG->wwwroot   = 'https://formation.univ-bfc.fr';
$CFG->dataroot  = '/home/moodledata';
$CFG->admin     = 'admin';
$CFG->directorypermissions = 0777;
require_once(__DIR__ . '/lib/setup.php');
// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
//$CFG->slasharguments = false;

Le thème utilisé est : Edumy

Avez-vous déjà ce problème ? Comment je peux y remédier

Merci

Alain


En réponse à Alain Dos Reis Pasquault

Re: Problème d'affichage depuis changement URL

par Alain Dos Reis Pasquault,
Bonjour à tous,

Depuis le temps, j'ai trouvé la solution.

En fait dans le fichier /etc/nginx/site-available/domain.conf voici la configuration si ça peut aider :
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name formation.domain.fr;
#        server_name _;
 location / {
        return 301 https://$host$request_uri;
    }
}
server {
        #listen 443 ssl http2 default_server;
        #listen [::]:443 ssl http2 default_server;

       listen 443 ssl http2 default_server;
       listen [::]:443 ssl http2 default_server;


        ssl_certificate /etc/nginx/certificate/fullchain2.pem;
        ssl_certificate_key /etc/nginx/certificate/privkey2.pem;
        ssl_session_timeout 1d;
        ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
        ssl_session_tickets off;
   listen 443 ssl http2 default_server;
       listen [::]:443 ssl http2 default_server;


        ssl_certificate /etc/nginx/certificate/fullchain2.pem;
        ssl_certificate_key /etc/nginx/certificate/privkey2.pem;
        ssl_session_timeout 1d;
        ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
        ssl_session_tickets off;

# # curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam
        ssl_dhparam /etc/nginx/dhparam;

# # intermediate configuration
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-EC$
        ssl_prefer_server_ciphers off;

# # HSTS (ngx_http_headers_module is required) (63072000 seconds)
        # a merttre si ssl # add_header Strict-Transport-Security "max-age=63072000" a$

# # Diffie-Hellman

        ssl_dhparam /etc/nginx/dhparam;

# # intermediate configuration
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-EC$
        ssl_prefer_server_ciphers off;

# # HSTS (ngx_http_headers_module is required) (63072000 seconds)
        # a merttre si ssl # add_header Strict-Transport-Security "max-age=63072000" a$

# # Diffie-Hellman
        ssl_ecdh_curve secp384r1;


# # OCSP stapling
        #ssl_stapling on;
        #ssl_stapling_verify on;

# # verify chain of trust of OCSP response using Root CA and Intermediate certs
        #ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

# # OCSP stapling
        #ssl_stapling on;
        #ssl_stapling_verify on;

# # verify chain of trust of OCSP response using Root CA and Intermediate certs
        #ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

        root /var/www/moodle;

        #index index.html index.htm index.php;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name formation.domaine.fr;
#        server_name _;

# # Privacy and security: opt out Google's FLoC Network
        add_header Permissions-Policy interest-cohort=();

# #     CSP (Content-Security-Policy) Contenu mixte
                add_header Content-Security-Policy "upgrade-insecure-requests; ";

        root /var/www/moodle;
# # OCSP stapling
        #ssl_stapling on;
        #ssl_stapling_verify on;

# # verify chain of trust of OCSP response using Root CA and Intermediate certs
        #ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

        root /var/www/moodle;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name formation.domain.fr;

# # Privacy and security: opt out Google's FLoC Network
        add_header Permissions-Policy interest-cohort=();

# #     CSP (Content-Security-Policy) Contenu mixte
                add_header Content-Security-Policy "upgrade-insecure-requests; ";
        index index.php index.html index.htm index.nginx-debian.html;
        server_name formation.univ-bfc.fr;
#        server_name _;

# # Privacy and security: opt out Google's FLoC Network
        add_header Permissions-Policy interest-cohort=();

# #     CSP (Content-Security-Policy) Contenu mixte
                add_header Content-Security-Policy "upgrade-insecure-requests; ";

       location / {
               try_files $uri $uri/ =404;
       }

# # pass PHP scripts to FastCGI server
        ###location ~ \.php$ {
        ###include snippets/fastcgi-php.conf;
        #

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
     }

# # pass PHP scripts to FastCGI server
        ###location ~ \.php$ {
        ###include snippets/fastcgi-php.conf;
        #

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }

include snippets/fastcgi-php.conf;

 # Mitigate https://httpoxy.org/ vulnerabilities
    fastcgi_param HTTP_PROXY "";



# # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
include snippets/fastcgi-php.conf;

 # Mitigate https://httpoxy.org/ vulnerabilities
    fastcgi_param HTTP_PROXY "";



# # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        ###fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_read_timeout 300;

# # include the fastcgi_param setting
    include fastcgi_params;

# # With php-cgi (or other tcp sockets):
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_cache nginxcache;
        fastcgi_cache_key $host$request_uri;
        fastcgi_cache_valid any 1h;
        fastcgi_cache_use_stale off;
        fastcgi_read_timeout 300;

# # include the fastcgi_param setting
    include fastcgi_params;

# # With php-cgi (or other tcp sockets):
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_cache nginxcache;
        fastcgi_cache_key $host$request_uri;
        fastcgi_cache_valid any 1h;
        fastcgi_cache_use_stale off;
        }
        error_page 404 /error/index.php; error_page 403 =404 /error/index.php;
# # Hide all dot files but allow "Well-Known URIs" as per RFC 5785
        location ~ /\.(?!well-known).*
        {
        return 404;
        }

# # This should be after the php fpm rule and very close to the last nginx ruleset.
        location ~ (/vendor/|/node_modules/|composer\.json|/readme|/README|readme\.txt$
        {
        deny all;

        error_page 404 /error/index.php; error_page 403 =404 /error/index.php;
# # Hide all dot files but allow "Well-Known URIs" as per RFC 5785
        location ~ /\.(?!well-known).*
        {
        return 404;
        }

# # This should be after the php fpm rule and very close to the last nginx ruleset.
        location ~ (/vendor/|/node_modules/|composer\.json|/readme|/README|readme\.txt$
        {
        deny all;
        return 404;
        }
}

Merci

Bien cordialement
Alain
Moyenne des évaluations Utile (1)