Einrichten eines virtuellen Hosts - Umleitung der Anforderung an die lokale IP-Adresse

Einrichten eines virtuellen Hosts - Umleitung der Anforderung an die lokale IP-Adresse

Ich möchte eine Anwendung, die auf Apache2 (Ubuntu) läuft, über das Internet verfügbar machen. Daher habe ich beschlossen, nach dem Kauf eines SSL-Zertifikats einen virtuellen Host einzurichten. In meinem lokalen Netzwerk funktioniert alles einwandfrei.

Wenn ich 172.16.2.28/moodle (im lokalen Netzwerk) besuche, funktioniert alles einwandfrei.

Wenn ich auch example.com besuche, wird mir die Standard-index.php von (/var/www/html) angezeigt.

Aber wenn ich example.com/moodle über das öffentliche Internet besuche, leitet der Browser zu 172.16.2.28/moodle weiter (mit Fehler 404).

Was mache ich falsch.

-

000-default.conf

<VirtualHost *:80>
     

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html



        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

  
</VirtualHost>

Standard-SSL.conf

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin [email protected]
                ServerName lms.xxx.com
                DocumentRoot /var/www/html 

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                
                SSLEngine on

                
                SSLCertificateFile      /home/vlms/sslcert/cert.pem
                SSLCertificateKeyFile /home/vlms/sslcert/cert.key

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                <Directory /var/www/html/>

                     Options +FollowSymlinks

                     AllowOverride All

                     Require all granted

                 </Directory>
    </VirtualHost>
</IfModule>

moodle/config.php(könnte das Problem hier liegen?)

<?php  // Moodle configuration file

unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype    = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost    = '172.16.0.30';
$CFG->dbname    = 'xxx';
$CFG->dbuser    = 'xxx';
$CFG->dbpass    = 'xxx';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
  'dbcollation' => 'utf8mb4_general_ci',
);

$CFG->wwwroot   = 'http://172.16.0.30/moodle';
$CFG->dataroot  = '/var/www/moodledata';
$CFG->admin     = 'xxx';

$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!

Antwort1

Moodle leitet Sie genau so weiter, wie Sie es konfiguriert haben:

$CFG->wwwroot   = 'http://172.16.0.30/moodle';

Ändern Sie diese Zeile in die richtige URL:

$CFG->wwwroot   = 'https://example.com/moodle';

verwandte Informationen