<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Nginx</id>
	<title>Nginx - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Nginx"/>
	<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Nginx&amp;action=history"/>
	<updated>2026-05-06T13:32:51Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Nginx&amp;diff=4415&amp;oldid=prev</id>
		<title>Олег Давидович: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Nginx&amp;diff=4415&amp;oldid=prev"/>
		<updated>2024-10-18T06:43:07Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 06:43, 18 октября 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Олег Давидович</name></author>
	</entry>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Nginx&amp;diff=4414&amp;oldid=prev</id>
		<title>1&gt;Adamjenkins: Added UPGRADING.md to the &quot;Hiding internal files&quot; configuration in preparation for Moodle 4.5 (See MDL-81125)</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Nginx&amp;diff=4414&amp;oldid=prev"/>
		<updated>2024-07-26T05:29:30Z</updated>

		<summary type="html">&lt;p&gt;Added UPGRADING.md to the &amp;quot;Hiding internal files&amp;quot; configuration in preparation for Moodle 4.5 (See MDL-81125)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Installing Moodle}}{{Update}}[[Nginx]] [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev. The nginx project started with a strong focus on high concurrency, high performance and low memory usage. It is licensed under the 2-clause BSD-like license and it runs on Linux, BSD variants, Mac OS X, Solaris, AIX, HP-UX, as well as on other *nix flavours. It also has a proof of concept port for Microsoft Windows.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;The following is community-contributed documentation on Nginx configuration. Amendments and additions are welcome.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Nginx configuration ==&lt;br /&gt;
&lt;br /&gt;
=== PHP-FPM ===&lt;br /&gt;
&lt;br /&gt;
Nginx is usually configured to interface with PHP via [http://php.net/manual/en/install.fpm.php php-fpm]. This is both fast and robust.&lt;br /&gt;
&lt;br /&gt;
PHP-FPM&amp;#039;s default behaviour for pools is usually to restrict the execution of scripts to a specific extension, i.e. .php. You should ensure that this behaviour is configured within your particular package/distribution, e.g. for debian,&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;/etc/php/7.4/fpm/pool.d/www.conf&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 security.limit_extensions = .php&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add the following &amp;#039;slash arguments&amp;#039; compatible &amp;#039;location&amp;#039; block to your vhosts &amp;#039;server&amp;#039; in your nginx configuration (further explanation at &amp;#039;[[Using slash arguments]]&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;nginx.conf location:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location ~ [^/]\.php(/|$) {&lt;br /&gt;
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;&lt;br /&gt;
    fastcgi_index            index.php;&lt;br /&gt;
    fastcgi_pass             127.0.0.1:9000 (or your php-fpm socket);&lt;br /&gt;
    include                  fastcgi_params;&lt;br /&gt;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;&lt;br /&gt;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the above does not work try the following:&lt;br /&gt;
Note: This was for CentOS 7.6 (1804), MariaDB 10.3, Nginx 1.15 and PHP 7.3.5&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location ~ ^(.+\.php)(.*)$ {&lt;br /&gt;
    root /usr/share/nginx/html/moodle/;&lt;br /&gt;
    fastcgi_split_path_info  ^(.+\.php)(.*)$;&lt;br /&gt;
    fastcgi_index            index.php;&lt;br /&gt;
    fastcgi_pass             127.0.0.1:9000;&lt;br /&gt;
    include /etc/nginx/mime.types;&lt;br /&gt;
    include                  fastcgi_params;&lt;br /&gt;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;&lt;br /&gt;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you find that this does not work (scripts, styles, and images not loading) &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; that there are &amp;lt;code&amp;gt;open() &amp;quot;...&amp;quot; failed (20: Not a directory)&amp;lt;/code&amp;gt; lines appearing in your logs: Check whether there are any directives related to static content &amp;#039;&amp;#039;&amp;#039;before&amp;#039;&amp;#039;&amp;#039; this block and try moving them &amp;#039;&amp;#039;&amp;#039;after&amp;#039;&amp;#039;&amp;#039; this block.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another potential pitfall is the use of &amp;#039;&amp;#039;&amp;#039;try_files&amp;#039;&amp;#039;&amp;#039;. Many guides recommend configurations like &amp;lt;pre&amp;gt;try_files $fastcgi_script_name =404;&amp;lt;/pre&amp;gt;. But if try_files is used, nginx deletes the content of the &amp;#039;&amp;#039;&amp;#039;$fastcgi_path_info&amp;#039;&amp;#039;&amp;#039; variable (this is [https://trac.nginx.org/nginx/ticket/321 intended behavior]). This causes &amp;#039;&amp;#039;&amp;#039;PATH_INFO&amp;#039;&amp;#039;&amp;#039; to also be empty, so slash arguments don&amp;#039;t work.&lt;br /&gt;
An alternative is the use of &amp;lt;pre&amp;gt;if(!-f $document_root$fastcgi_script_name) {return 404;}&amp;lt;/pre&amp;gt; [https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/#connecting-nginx-to-php-fpm as recommended] by the nginx documentation, although the nginx documentation also recommends [https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/ not using if].&lt;br /&gt;
&lt;br /&gt;
==== Error pages ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This passes 404 pages to Moodle so they can be themed&lt;br /&gt;
error_page 404 /error/index.php;    error_page 403 =404 /error/index.php;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Hiding internal files ====&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Hide all dot files but allow &amp;quot;Well-Known URIs&amp;quot; as per RFC 5785&lt;br /&gt;
location ~ /\.(?!well-known).* {&lt;br /&gt;
    return 404;&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
# This should be after the php fpm rule and very close to the last nginx ruleset.&lt;br /&gt;
# Don&amp;#039;t allow direct access to various internal files. See MDL-69333&lt;br /&gt;
location ~ (/vendor/|/node_modules/|composer\.json|/readme|/README|readme\.txt|/upgrade\.txt|/UPGRADING\.md|db/install\.xml|/fixtures/|/behat/|phpunit\.xml|\.lock|environment\.xml) {&lt;br /&gt;
    deny all;&lt;br /&gt;
    return 404;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== XSendfile aka X-Accel-Redirect ====&lt;br /&gt;
&lt;br /&gt;
Setting Moodle and Nginx to use XSendfile functionality is a big win as it frees PHP from delivering files allowing Nginx to do what it does best, i.e. deliver files. &lt;br /&gt;
&lt;br /&gt;
Enable xsendfile for Nginx in Moodles config.php, this is documented in the config-dist.php, a minimal configuration look like this,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;xsendfile = &amp;#039;X-Accel-Redirect&amp;#039;;&lt;br /&gt;
$CFG-&amp;gt;xsendfilealiases = array(&lt;br /&gt;
    &amp;#039;/dataroot/&amp;#039; =&amp;gt; $CFG-&amp;gt;dataroot&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Accompany this with a matching &amp;#039;location&amp;#039; block in your nginx server configuration.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /dataroot/ {&lt;br /&gt;
    internal;&lt;br /&gt;
    alias &amp;amp;lt;full_moodledata_path&amp;amp;gt;; # ensure the path ends with /&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The definition of &amp;#039;internal&amp;#039; here is &amp;#039;&amp;#039;&amp;#039;critical&amp;#039;&amp;#039;&amp;#039; as it prevents client access to your dataroot.&lt;br /&gt;
&lt;br /&gt;
==== Load Balancer Hints (AWS) ====&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;re using an AWS load balancer in front your infrastructure, you can set up some of the configuration above, preventing traffic to go forward. Here is the configuration applied to hide files, with a few considerations due to known limitations:&lt;br /&gt;
* 100 total rules per application load balancer&lt;br /&gt;
* 5 condition values per rule&lt;br /&gt;
* 5 wildcards per rule&lt;br /&gt;
* 5 weighted target groups per rule:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;Conditions&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Field&amp;quot;: &amp;quot;path-pattern&amp;quot;, &lt;br /&gt;
                &amp;quot;Values&amp;quot;: [&lt;br /&gt;
                    &amp;quot;*/.*&amp;quot;, &lt;br /&gt;
                    &amp;quot;*/upgrade.txt&amp;quot;, &lt;br /&gt;
                    &amp;quot;*/db/install.xml&amp;quot;,&lt;br /&gt;
                    &amp;quot;*/README.md&amp;quot;&lt;br /&gt;
                ], &lt;br /&gt;
                &amp;quot;PathPatternConfig&amp;quot;: {&lt;br /&gt;
                    &amp;quot;Values&amp;quot;: [&lt;br /&gt;
                        &amp;quot;*/.*&amp;quot;, &lt;br /&gt;
                        &amp;quot;*/upgrade.txt&amp;quot;, &lt;br /&gt;
                        &amp;quot;*/db/install.xml&amp;quot;,&lt;br /&gt;
                        &amp;quot;*/README.md&amp;quot;&lt;br /&gt;
                    ]&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ], &lt;br /&gt;
        &amp;quot;Actions&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Type&amp;quot;: &amp;quot;fixed-response&amp;quot;, &lt;br /&gt;
                &amp;quot;Order&amp;quot;: 1, &lt;br /&gt;
                &amp;quot;FixedResponseConfig&amp;quot;: {&lt;br /&gt;
                    &amp;quot;ContentType&amp;quot;: &amp;quot;text/html&amp;quot;, &lt;br /&gt;
                    &amp;quot;MessageBody&amp;quot;: &amp;quot;&amp;lt;html&amp;gt;\n&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;404 Not Found&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;\n&amp;lt;body&amp;gt;\n&amp;lt;center&amp;gt;&amp;lt;h1&amp;gt;404 Not Found&amp;lt;/h1&amp;gt;&amp;lt;/center&amp;gt;\n&amp;lt;hr&amp;gt;\n&amp;lt;/body&amp;gt;\n&amp;lt;/html&amp;gt;&amp;quot;, &lt;br /&gt;
                    &amp;quot;StatusCode&amp;quot;: &amp;quot;404&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ]&lt;br /&gt;
    }, &lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;Conditions&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Field&amp;quot;: &amp;quot;path-pattern&amp;quot;, &lt;br /&gt;
                &amp;quot;Values&amp;quot;: [&lt;br /&gt;
                    &amp;quot;*/composer.json&amp;quot;, &lt;br /&gt;
                    &amp;quot;*/Gruntfile.js&amp;quot;,&lt;br /&gt;
                    &amp;quot;*.lock&amp;quot;, &lt;br /&gt;
                    &amp;quot;*/environtment.xml&amp;quot;,&lt;br /&gt;
                    &amp;quot;*/readme.txt&amp;quot;&lt;br /&gt;
                ], &lt;br /&gt;
                &amp;quot;PathPatternConfig&amp;quot;: {&lt;br /&gt;
                    &amp;quot;Values&amp;quot;: [&lt;br /&gt;
                        &amp;quot;*/composer.json&amp;quot;, &lt;br /&gt;
                        &amp;quot;*/Gruntfile.js&amp;quot;,&lt;br /&gt;
                        &amp;quot;*.lock&amp;quot;, &lt;br /&gt;
                        &amp;quot;*/environtment.xml&amp;quot;,&lt;br /&gt;
                        &amp;quot;*/readme.txt&amp;quot;&lt;br /&gt;
                    ]&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ], &lt;br /&gt;
        &amp;quot;Actions&amp;quot;: [ #### Same as above&lt;br /&gt;
            ...&lt;br /&gt;
        ]&lt;br /&gt;
    }, &lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;Conditions&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Field&amp;quot;: &amp;quot;path-pattern&amp;quot;, &lt;br /&gt;
                &amp;quot;Values&amp;quot;: [&lt;br /&gt;
                    &amp;quot;*/fixtures/*&amp;quot;, &lt;br /&gt;
                    &amp;quot;*/behat/*&amp;quot;, &lt;br /&gt;
                    &amp;quot;*/phpunit.xml&amp;quot;&lt;br /&gt;
                ], &lt;br /&gt;
                &amp;quot;PathPatternConfig&amp;quot;: {&lt;br /&gt;
                    &amp;quot;Values&amp;quot;: [&lt;br /&gt;
                        &amp;quot;*/fixtures/*&amp;quot;, &lt;br /&gt;
                        &amp;quot;*/behat/*&amp;quot;, &lt;br /&gt;
                        &amp;quot;*/phpunit.xml&amp;quot;&lt;br /&gt;
                    ]&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        ], &lt;br /&gt;
        &amp;quot;Actions&amp;quot;: [ #### Same as above&lt;br /&gt;
            ...&lt;br /&gt;
        ]&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* Real &amp;lt;tt&amp;gt;PATH_INFO&amp;lt;/tt&amp;gt; support:&lt;br /&gt;
** https://moodle.org/mod/forum/discuss.php?d=278916&lt;br /&gt;
** https://moodle.org/mod/forum/discuss.php?d=307388&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[Deprecated]&amp;#039;&amp;#039;&amp;#039; Internal rewriting to the HTTP GET &amp;lt;tt&amp;gt;file&amp;lt;/tt&amp;gt; parameter:&lt;br /&gt;
** https://moodle.org/mod/forum/discuss.php?d=83445&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[es:Nginx]]&lt;br /&gt;
[[pt-br:Nginx]]&lt;/div&gt;</summary>
		<author><name>1&gt;Adamjenkins</name></author>
	</entry>
</feed>