0

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 [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 (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! 
2
  • 1
    There are no redirects there. It sounds like your redirect is coming from Moodle. Commented Aug 18, 2020 at 0:55
  • @MichaelHampton Thanks for your response, I edited the post. I added the moodle/config.php file, please see if you can figure out where i went wrong. Thanks Commented Aug 18, 2020 at 7:13

2 Answers 2

0

Moodle redirects you exactly how you configured it:

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

Change that line to the proper URL:

$CFG->wwwroot = 'https://example.com/moodle'; 
2
  • Thanks @GeraldSchneider . It works now. But I still get some error in console. Mixed Content: The page at 'lms.xxx.com/moodle' was loaded over HTTPS, but requested an insecure image '172.16.0.30/moodle/?redirect=0'. This content should also be served over HTTPS. Any Idea? Commented Aug 18, 2020 at 14:17
  • Check the developer tools of your browser which images are affected, find out where their URLs come frome and correct them. Commented Aug 18, 2020 at 15:24
0

enter code hereI had the same issue what worked for me was this Moodle was extracted to a folder mayol in /var/www my vhost config is below

<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/mayol/smiles/ ServerName mysite.ng #ServerAlias www.mysite.ng <Directory /var/www/mayol/moodledata/> Options FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/mysitename_error.log CustomLog ${APACHE_LOG_DIR}/mysitename_access.log combined </VirtualHost> 

also ensure you have the right path specified in the config.php

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.