Nginx configuration

<p>Configure Nginx for <a href="https://www.rainloop.net/">Rainloop</a> usage.</p> <!-- RATIONALE --> <p>Nginx requires specific settings to match Rainloop's way of working.</p> <h2>Procedure</h2> <!-- NARRATIVE FORM --> <p>Have Nginx not refer to the default "It works" directory / page. Provide Nginx with a configuration file to: have it listen on port 80 for all addresses, set the root for the hosted files looking for index or index.php files, make it look in specific places and return a 404 message if unsuccessful, and have PHP deal with the .php scripts found.</p> <!-- STEP BY STEP --> <ol> <li> <p>Disable the Nginx default vhost:</p> <pre><code class="language-shell">unlink /etc/nginx/sites-enabled/default</code></pre> </li> <li> <p>Create the Nginx configuration file to create a vhost that listens to all http request on port 80:</p> <pre><code class="language-shell"># Redirect the following block until End Of File (EOF) via `cat` to a webmail file cat &lt;&lt; 'EOF' &gt; /etc/nginx/sites-enabled/webmail # Settings for the first (and only) server server { # Make the default Nginx vhost listen on port 80 listen 80 default_server; # Define the path to look for files root /var/www/rainloop; # Define the default files to look for (when no file is referenced request URL) index index.php; # Instruct Nginx to recursively look (starting from the root defined above), for 1:files 2:directories (referenced in the request URL) and 3) return a 404 otherwise. location / { try_files $uri $uri/ =404; } # Process all files with a `.php` extension location ~ \.php$ { # Split the input into two groups, filename and its arguments (title.php?page=landing -&gt; title.php / ?page=landing) fastcgi_split_path_info ^(.+\.php)(/.+)$; # Define the socket file that is used as the php-fpm "interface" to send stuff to fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # Send the fastcgi params (basically a set of default PHP "environment" variables) include fastcgi_params; # Add a specific parameter appending the already included list fastcgi_param SCRIPT_FILENAME $request_filename; } } EOF</code></pre> </li> <li> <p>Restart Nginx service to effectuate the changes:</p> <pre><code class="language-shell">service nginx restart</code></pre> <!-- REFERENCES --> </li> </ol>