Moodle 3.5 with Reverse proxy - proxy

I'm having troubles setting up a moodle instance behind an apache proxy.
Here's my apache front-end that proxies to the running server.
<VirtualHost *:80>
ServerName public.domain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://10.10.10.10:81/moodle/
ProxyPassReverse / http://10.10.10.10:81/moodle/
</VirtualHost>
AND.
$CFG->wwwroot = 'http://public.domain.com';
I install without problems, but when finished the installation I try in browser:
http://public.domain.com
This redirect to: http://public.domain.com/moodle/index.php?sessionstarted=1&lang=en...
Does anyone know what might be happening?

The best way to fix this issue is to move the moodle installation on the internal host to the root of web server.
Move your moodle in 10.10.10.10 to be at / and not at /moodle
Note, that if you will use SSL on the external apache (it's suggested) you should also add to your config this line:
$CFG->sslproxy = true;

Finally I have been able to fix the problem, I am writing this answer with a bigger level of detail so other people having this problem can follow my answer.
First we need to edit the apache2 config for our site:
In general the apache2 configuration for your specified site can be found at /etc/apache2/sites-enabled. Depending if you are using http or https you need to edit the right configuration file. Default name for http is 000-default.conf and for https 000-default-ssl.conf
Add the following lines between the <VirtualHost *:80>....</VirtualHost> sections.
# MOODLE
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "http://10.10.10.10:81/moodle/"
ProxyPassReverse "/" "http://10.10.10.10:81/moodle/"
Then we need to restart our apache2 webserver, this can be done with the command service apache2 restart.
Now we also need to edit a few things in our moodle config.php file. This file can be found at /var/www/html/moodle on the server with the IP (in this case) 10.10.10.10 if you used the default install location from the moodle guides.
In the config.php file we append the following lines under the default $CFG declarations: Please make sure to change all values according to your server setup.
$CFG->wwwroot = 'http://public.domain.com';
$CFG->dirroot = '/var/www/html/moodle';
$CFG->reverseproxy = true;
//$CFG->sslproxy = true; //UNCOMMENT this line if you are using SSL
Attention: If you are not using the root directory at your public webserver, then make sure that you do not use the same directory as moodle is using on the subserver. For example http://public.domain.com/moodle will fail if moodle is installed on the subserver at /var/html/moodle since both directories are equal and the proxy loops for some reason. My easy fix for this problem was do just move the moodle installation to /var/html/moodley including all required changes in the config.php. This fixes every problem I had.

Related

Laravel 5.5 CRUD on Chrome

I am currently trying to run the program after I have successfully created all the necessary CRUD files. Note that I am following this tutorial here.
However, I am facing problem in trying to run the sites from my cmd. I tried taskmanager.dev but Chrome returned 'This site can’t be reached'.
May I know, is the any specific ways for me to run the site on xampp?
I am using Windows.
Please help. Thank You.
I am quite sure the guy who made the tutorial is using valet.
Just use php artisan serve and you will be able to connect to your site on localhost.
But if you really want to use taskmanager.dev do the following:
Open the hosts file, which is lotcated # C:\Windows\System32\drivers\etc\hosts
Add 127.0.0.1 taskmanager.dev at the bottom
Make sure you follow their installation tutorial closely. It sounds like you may not have configured the server correctly.
For me, I have to edit my VHosts file which is in:
C:\xampp\apache\conf\extra
And to edit my hosts file I need to go to:
C:\Windows\System32\drivers\etc
If all else fails you can always just run php artisan serve in bash to launch your app.
But I would recommend going through these instructions again:
XAMPP Virtual Host
We need to configure XAMPP Virtual Host to set the document root to correct directory of laravel project and to also assign a name to the project by which we will be accessing it in browser.
Navigate and open file /Applications/XAMPP/etc/httpd.conf file and uncomment the line that includes the virtual host file.
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Navigate and open file /Applications/XAMPP/etc/extra/httpd-vhosts.conf and include following Virtual host entry in this file.
# VirtualHost for TASKMANAGER.DEV
<VirtualHost taskmanager.dev:80>
DocumentRoot "C:\xampp\htdocs\taskmanager\public"
ServerAdmin taskmanager.dev
<Directory "C:\xampp\htdocs\taskmanager">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
With this entry our apache is listening to taskmanager.dev, but we also have to edit our hosts file to include an entry for the new domain.
Edit file /etc/hosts and add following entry to that file.
127.0.0.1 taskmanager.dev
Restart your apache and access taskmanager.dev on your browser you should be able to see this screen.
Chrome 63 now enforces .dev domains via HTTPS. Follow this article : https://laravel-news.com/chrome-63-now-forces-dev-domains-https to know more.
I've changed to .test for my valet domains. Hope this helps. Thank you.

how to configure laravel site on localhost using xampp

I am trying to configure the site in localhost which is developed on laravel.
Now I am trying to configure it on my local Machine, using xampp version 3.2.1 and php version 5.6.11 & mysql DB.
I am able to configure it but other than home page all links get 404 page not found error
any suggestions
Enable the rewrite_module in apache's configuration file.
If you are not aware of how to do this, follow below steps:
1) Open apache's configuration file using your favorite text editor. The configuration file generally locates at:{apache_dir}/conf/httpd.conf
If you are using XAMPP or WAMP package then you will find the file at:{xampp_dir}/apache/conf/httpd.conf (or)
{wamp_dir}/apache/conf/httpd.conf
2) Search for the following string:#LoadModule rewrite_module modules/mod_rewrite.so and uncomment it (remove the '#' sign).
3) Now search for another string AllowOverride None and replace it by AllowOverride All
4) Finally save the changes, close your text editor and restart your apache server.
Hope this will help you, Thank you.

Use https on localhost xampp on mac

I have been trying to use my xampp in localhost with https.
1/ The first step (certificate creation) seems okay. I generated a crt & a key using openssl. Using *.frenchpie.com as common name.
2/ I then copied those two respectively in /etc/ssl.crt/ & /etc/ssl.key/ folders.
3/ I did the following in httpd-vhosts.conf using what I found on stackoverflow
<VirtualHost *:443>
DocumentRoot C:/xampp/htdocs/frenchpie
ServerName local.frenchpie.com
SSLEngine on
SSLCertificateFile "conf/ssl.crt/frenchpie.crt"
SSLCertificateKeyFile "conf/ssl.key/frenchpie.key"
</VirtualHost>
4/ Of course I restarted xampp
Please note that I did not change anything else.
The website main folder is "frenchpie" in htdocs. Also 127.0.0.1 is mapped to local.frenchpie.com
Using http://local.frenchpie.com/frenchpie works as usual (homepage).
Using https://local.frenchpie.com/frenchpie gives me a certificate error (see picture).
Any help appreciated.
If you generate a certificate with OpenSSL, when you visit your page from anyone browser you will have a error message because you create your own certificate.
All browsers have some root certificates by default (Symantec, Comodo etc). When you visit a website with https, they check if your certificate is generate by anyone of their default root certificates. However you can add new root certificates to your browser.
If you want a public website you are going to need a trusty certificate, so you will need to buy one.

Changing Magento domain breaks URL rewrites

I'm just launching my first Magento store (on CentOS & Apache) and I've switched over from my setup subdomain - http://prelive.mydomain.com (where everything worked fine, with url rewriting enabled & working) - to the live subdomain http://www.mydomain.com, basically just by doing the following:
clearing caches via the admin interface
updating the secure & unsecure base urls in the db
UPDATE core_config_data SET value = 'http://www.mydomain.co.uk/' WHERE path = 'web/unsecure/base_url';
UPDATE core_config_data SET value = 'https://www.mydomain.co.uk/' WHERE path = 'web/secure/base_url';
moving the entire site file system from /var/www/html/prelive to /var/www/html/www (I tried copying but it caused all sorts of permission problems which I'll figure out later!)
manually editing the media base path in var/resource_config.json
updating my virtual host like this:
<VirtualHost *:80>
DocumentRoot /var/www/html/www
ServerName www.mydomain.co.uk
ServerAlias www.mydomain.co.uk
ErrorLog logs/www.mydomain.co.uk-error_log
</VirtualHost>
editing the base .htaccess file like this ()
SetEnvIf Host www\.mydomain.co.uk MAGE_RUN_CODE=angling_r_en
SetEnvIf Host www\.mydomain.co.uk MAGE_RUN_TYPE=store
SetEnvIf Host ^mydomain.co.uk MAGE_RUN_CODE=angling_r_en
SetEnvIf Host ^.mydomain.co.uk MAGE_RUN_TYPE=store
And it almost works... but the url rewriting is broken. I can see the site on http://www.mydomain.com but navigating to subpages gets a 404 (e.g. http://www.mydomain.com/path/to/product.html ), unless I specifically alter the URL to point through index.php like this http://www.mydomain.com/index.php/path/to/product.html or http://www.mydomain.com/index.php/admin
For reference, in .htaccess I also have (left unchanged during the switch of subdomain):
RewriteBase /
and
RewriteRule .* index.php [L]
Any thoughts on what I forgot?
Many thanks
Ben
Most likely you need to reindex the catalog URL rewrites to incorporate your new URL changes! See System > Index Management and reindex the Catalog URL Rewrites.
Ok - so the problem was on the server all along, not Magento...
Basically rewrites weren't working because I needed this in both my VirtualHost container in both both httpd.conf and ssl.conf:
<Directory /var/www/html/www>
AllowOverride All
</Directory>
What I still don't understand is how it worked on the old location (which definitely didn't have this) and not the new one... but it works just the same as before now, with "Use Web Server Rewrites" turned on in System > Configuration > Web, creating "clean" urls which are rewritten through index.php by mod_rewrite.

Error getting images to show up in Symfony 1.4.8

Note: It was tough deciding whether this belonged here or ServerFault, but it seemed like a programming problem, so if it's out of place, feel free to migrate it.
I downloaded the sandbox of Symfony 1.4.8 and copied the files to my webserver. Unfortunately, when I try to access /symfony/sf_sandbox/web/ (where I installed it), I get the following:
It seems like the images aren't showing. According to the text:
If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf/ directory.
However, when I try to locate the folder referenced above, it does not exist:
sf_sandbox
web
css/
images/
js/
uploads/
frontend_dev.php
index.php
robots.txt
As you can see, there is no sf/ directory under web/. What am I doing wrong?
Note: I am installing this on Ubuntu 10.04 64-bit using Apache.
All the images are located in the Symfony source directory.
I would try creating a symbolic link in the web folder called sf pointed to the following:
lib\vendor\symfony\data\web\sf
It should have access to the needed images at that point.
This is done by indicating the right path in the Alias directive in your apache configuration:
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/home/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Just replace "/home/sfprojects/jobeet" with your project's path and it should work.
This page shows the apache config to set up a new project correctly.
There are also important security notes for your webapp.
Symfony Documentation
All you need to do is copy the whole sf folder to the web folder. In my case i copied c:\wamp\www\jobeet\lib\vendor\symfony\data\web\sf\ to c:\wamp\www\jobeet\web. Hope that makes sense

Resources