Activate slash arguments in nginx (windows)

Activate slash arguments in nginx (windows)

by Markus W -
Number of replies: 6

Hi,

I  am trying to install moodle on nginx instead on apache, and it comes with a few problems.

After a really long install, it's finally done, but slasharguments won't work. (moodle looks like it has no graphics or css files at all)


I tried adding following part to the nginx.conf file:

location ~ \.php(.*)$ {
			include fastcgi_params;
			fastcgi_index index.php;
			if (!-e $request_filename) {
			rewrite ^(.*\.php)(/)(.*)$ $1?file=/$3 last;
			}
			fastcgi_param SCRIPT_FILENAME ..\WWW\moodle2.9\html$fastcgi_script_name;
			fastcgi_pass 127.0.0.1:9000;
			fastcgi_read_timeout 250s;
		}
My path are those: 

Moodle root: C:\Program Files (x86)\nginx\WT-NMP\WWW\moodle2.9 

Conf-files: C:\Program Files (x86)\nginx\WT-NMP\conf


nginx will not start anymore as soons as I put in this code snippet. Can somebody help me?

Thank you very much 


Average of ratings: -
In reply to Markus W

Re: Activate slash arguments in nginx (windows)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

A quick look turned up a few pages on the subject (mostly people struggling it seems)... e.g., http://kbeezie.com/php-self-path-nginx/

Note that you can disable slasharguments in Moodle but this option is going to disappear in the next version or two so it's probably best to resolve it on the server.  

In reply to Howard Miller

Re: Activate slash arguments in nginx (windows)

by Markus W -
I'm not sure how this could help me. Isn't it just about  PHP_SELF and so on, which gave the user wrong values?
I can't see something that would help the slasharguments problem in moodle. I have found a configuration for the "location" setting in the conf file, but nginx won't start anymore. I assume there is something wrong, but I can't see the problem. I never used nginx before.


edit: I actually found the code, just put this in server section in the config file:

rewrite ^/moodle2.9/(.*\.php)(/)(.*)$ /moodle2.9/$1?file=/$3 last;

Where actually moodle2.9 is my subdirectory.
In reply to Markus W

Re: Activate slash arguments in nginx (windows)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Solution was for PATH_INFO and PHP_SELF. PATH_INFO is what you are missing. 

In reply to Markus W

Re: Activate slash arguments in nginx (windows)

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Markus,
please do not internally rewrite PATH_INFO into the HTTP GET file param: just use it in a plain way as described in https://docs.moodle.org/29/en/Nginx#Slasharguments.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Activate slash arguments in nginx (windows)

by Markus W -

Hi Matteo,

I put the location config from your link into my nginx conf file, but like before, the nginx server will not start anymore. Are there some changes needed? Thanks for your reply.

Markus

In reply to Markus W

Re: Activate slash arguments in nginx (windows)

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Markus,
that's is a running configuration in a Linux box (an example: https://moopi.mrverrall.co.uk/course/view.php?id=4).

You should find in the log message - http://nginx.org/en/docs/debugging_log.html - the reason why the server starts no more, probably a typo or too many "similar" sections. You should post here the relevant logs, hoping that someone using nginx in Windows will have ideas about your error.

HTH,
Matteo