I have a wordpress installation using Nginx as the web server, now there is a need of adding moodle as the LMS to the same site, as a subdirectory, for example; www.mysite.com
is where the wordpress site works then moodle would be www.mysite.com/learn
.
This moodle runs in the same machine in a docker container which uses the bitnami moodle image; port 8081
is mapped to port 80
of the docker container i.e.
docker run -d -p 8081:80 -p 4443:443 --name moodle
I added a location block before wordpress configuration to the nginx config
location /learn {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass http://0.0.0.0:8081;
}
the php configuration for wordpress is as follows
# Pass the PHP scripts to FastCGI server (locally with unix: param to avoid network overhead)
location ~ \.php$ {
# Prevent Zero-day exploit
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APP_ENV production;
include fastcgi_params;
}
However this still gives a 404 response when I access www.amysite.com/learn
I checked the docker proxy is running bound to all IP addresses
/usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8081 -container-ip 172.19.0.3 -container-port 80
also a wget
to localhost:8081
gives the moodle installation home page so I'm led to belive it is definitely a problem with my location block; or it is the Zero Day exploit config try_files $uri =404;
causing the issue, even if so, I still can't remove that line.
Update
This configuration worked
location ~ ^/apply/(.*)$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass http://0.0.0.0:8081/$1;
}
I can reach Moodle home page but all further URLs break because Moodle is not aware of generating links with the /learn
context root; think I'll have to reconfigure Moodle to generate /learn
context URLS
0 Answers