I want to make an application running on apache2 (ubuntu) available over the internet. So i decided to setup virtual host after purchasing a SSL certificate. Everything works fine on my Local network.
When I visit 172.16.2.28/moodle (on local network), Everything works fine.
When I also visit example.com, I am served the default index.php from (/var/www/html)
But when I visit example.com/moodle over public internet, the browser redirects to 172.16.2.28/moodle (with error 404)
What am I doing wrong.
-
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 sa@xxx.com
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 (could the problem be from here?)
<?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!