가상 호스트 설정 요청을 로컬 IP 주소로 리디렉션

가상 호스트 설정 요청을 로컬 IP 주소로 리디렉션

인터넷을 통해 사용할 수 있는 apache2(우분투)에서 실행되는 애플리케이션을 만들고 싶습니다. 그래서 SSL 인증서를 구입한 후 가상 호스트를 설정하기로 결정했습니다. 내 로컬 네트워크에서는 모든 것이 잘 작동합니다.

172.16.2.28/moodle(로컬 네트워크)을 방문하면 모든 것이 잘 작동합니다.

example.com을 방문하면 (/var/www/html)에서 기본 index.php가 제공됩니다.

하지만 공용 인터넷을 통해 example.com/moodle을 방문하면 브라우저가 172.16.2.28/moodle로 리디렉션됩니다(오류 404).

내가 도대체 ​​뭘 잘못하고있는 겁니까.

-

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>

default-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>

무들/config.php(여기서 문제가 발생하는 걸까요?)

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

답변1

Moodle은 구성한 대로 정확하게 리디렉션합니다.

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

해당 줄을 적절한 URL로 변경하세요.

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

관련 정보