Combine nginx_example and nginx into one page

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke
2017-05-14 13:29:55 -05:00
parent a131b4d3e6
commit dc676ca45e
7 changed files with 68 additions and 88 deletions

View File

@@ -59,7 +59,7 @@ describe how to enable HTTPS on the Apache and Nginx Web servers.
:ref:`use_https_label`
:doc:`../installation/nginx_examples`
:doc:`../installation/nginx`
The test with getenv(\"PATH\") only returns an empty response
-------------------------------------------------------------

View File

@@ -13,5 +13,4 @@ Installation
apps_management_installation
apps_supported
selinux_configuration
nginx_examples
nginx

View File

@@ -2,12 +2,25 @@
Nginx Configuration
===================
The following configuration should be used when Nextcloud is placed in the
webroot of your Nginx installation. Be careful about line breaks if you copy
the examples, as long lines may be broken for page formatting.
This page covers example Nginx configurations to use with running an Nextcloud
server. This page is community-maintained. (Thank you, contributors!)
Some environments might need a ``cgi.fix_pathinfo`` set to ``1`` in their
``php.ini``.
- You need to insert the following code into **your Nginx configuration file.**
- Adjust **server_name**, **root**, **ssl_certificate** and
**ssl_certificate_key** to suit your needs.
- Make sure your SSL certificates are readable by the server (see `nginx HTTP
SSL Module documentation <http://wiki.nginx.org/HttpSslModule>`_).
- ``add_header`` statements are only taken from the current level and are not
cascaded from or to a different level. All necessary ``add_header``
statements must be defined in each level needed. For better readability it
is possible to move *common* add header statements into a separate file
and include that file wherever necessary. However, each ``add_header``
statement must be written in a single line to prevent connection problems
with sync clients.
- Be careful about line breaks if you copy the examples, as long lines may be
broken for page formatting.
- Some environments might need a ``cgi.fix_pathinfo`` set to ``1`` in their
``php.ini``.
Thanks to `@josh4trunks <https://github.com/josh4trunks>`_ for providing /
creating these configuration examples.
@@ -15,8 +28,9 @@ creating these configuration examples.
Nextcloud in the webroot of nginx
---------------------------------
The following config should be used when Nextcloud is placed in the webroot of
your nginx installation.
The following configuration should be used when Nextcloud is placed in the
webroot of your nginx installation. In this example it is
``/var/www/nextcloud`` and it is accessed via ``http(s)://cloud.example.com``
.. code-block:: nginx
@@ -273,4 +287,43 @@ your nginx installation.
}
}
}
Tips and Tricks
---------------
Suppressing Log Messages
========================
If you're seeing meaningless messages in your logfile, for example ``client
denied by server configuration: /var/www/data/htaccesstest.txt``, add this section to
your nginx configuration to suppress them:
.. code-block:: nginx
location = /data/htaccesstest.txt {
allow all;
log_not_found off;
access_log off;
}
JavaScript (.js) or CSS (.css) files not served properly
========================================================
A common issue with custom nginx configs is that JavaScript (.js)
or CSS (.css) files are not served properly leading to a 404 (File not found)
error on those files and a broken webinterface.
This could be caused by the:
.. code-block:: nginx
location ~* \.(?:css|js)$ {
block shown above not located **below** the:
.. code-block:: nginx
location ~ \.php(?:$|/) {
block. Other custom configurations like caching JavaScript (.js)
or CSS (.css) files via gzip could also cause such issues.

View File

@@ -1,75 +0,0 @@
============================
Nginx Example Configurations
============================
This page covers example Nginx configurations to use with running an Nextcloud
server. This page is community-maintained. (Thank you, contributors!)
- You need to insert the following code into **your Nginx configuration file.**
- The configuration assumes that Nextcloud is installed in
``/var/www/nextcloud`` and that it is accessed via
``http(s)://cloud.example.com``.
- Adjust **server_name**, **root**, **ssl_certificate** and
**ssl_certificate_key** to suit your needs.
- Make sure your SSL certificates are readable by the server (see `nginx HTTP
SSL Module documentation <http://wiki.nginx.org/HttpSslModule>`_).
- ``add_header`` statements are only taken from the current level and are not
cascaded from or to a different level. All necessary ``add_header``
statements must be defined in each level needed. For better readability it
is possible to move *common* add header statements into a separate file
and include that file wherever necessary. However, each ``add_header``
statement must be written in a single line to prevent connection problems
with sync clients.
Example Configurations
----------------------
- :doc:`nginx`
You can use Nextcloud over plain http, but we strongly encourage you to use
SSL/TLS to encrypt all of your server traffic, and to protect user's logins and
data in transit.
- Remove the server block containing the redirect
- Change **listen 443 ssl** to **listen 80;**
- Remove **ssl_certificate** and **ssl_certificate_key**.
- Remove **fastcgi_params HTTPS on;**
Suppressing Log Messages
========================
If you're seeing meaningless messages in your logfile, for example `client
denied by server configuration: /var/www/data/htaccesstest.txt
<https://forum.owncloud.org/viewtopic.php?f=17&t=20217>`_, add this section to
your nginx configuration to suppress them:
.. code-block:: nginx
location = /data/htaccesstest.txt {
allow all;
log_not_found off;
access_log off;
}
JavaScript (.js) or CSS (.css) files not served properly
========================================================
A common issue with custom nginx configs is that JavaScript (.js)
or CSS (.css) files are not served properly leading to a 404 (File not found)
error on those files and a broken webinterface.
This could be caused by the:
.. code-block:: nginx
location ~* \.(?:css|js)$ {
block shown above not located **below** the:
.. code-block:: nginx
location ~ \.php(?:$|/) {
block. Other custom configurations like caching JavaScript (.js)
or CSS (.css) files via gzip could also cause such issues.

View File

@@ -454,7 +454,7 @@ be set in the ``nextcloud/.user.ini`` file.
Other Web Servers
-----------------
:doc:`nginx_examples`
:doc:`nginx`
`Other HTTP servers (Nextcloud)

View File

@@ -261,8 +261,8 @@ and if running in a subfolder like ``nextcloud``:
For the first case the :file:`.htaccess` file shipped with Nextcloud should do
this work for your when running Apache. You only need to make sure that your
Web server is using this file. When running NGINX please refer to
:doc:`../installation/nginx_examples`.
Web server is using this file. When running Nginx please refer to
:doc:`../installation/nginx.
If your Nextcloud instance is installed in a subfolder called ``nextcloud`` and

View File

@@ -15,6 +15,9 @@ Updates to Nginx configuration
those lines in your Nginx config:
``add_header X-Frame-Options "SAMEORIGIN";``
See :doc:`installation/nginx`
* For improvements in serving HTTP requests the Nginx configuration now has
HTTP 2 enabled. Please update your Nginx config accordingly. See
:doc:`installation/nginx`
Q & A
-----