Nginx.conf: различия между версиями

Материал из Webko Wiki
Перейти к навигации Перейти к поиску
(Новая страница: «Категория:OwnCloud»)
 
 
Строка 1: Строка 1:
 
[[Категория:OwnCloud]]
 
[[Категория:OwnCloud]]
 +
<syntaxhighlight lang="bash">
 +
worker_processes 4;
 +
 +
error_log /opt/data/owncloud/log/nginx_error.log warn;
 +
 +
events {
 +
    worker_connections  1024;
 +
}
 +
 +
http {
 +
 +
    include ../nginx/conf/mime.types;
 +
 +
    upstream php-handler {
 +
        server unix:/opt/app/owncloud/php/var/php5-fpm.sock;
 +
    }
 +
 +
    server {
 +
        listen 1082;
 +
        server_name localhost;
 +
 +
        root /opt/app/owncloud/owncloud;
 +
        client_max_body_size 10G;
 +
 +
        fastcgi_buffers 64 4K;
 +
        fastcgi_read_timeout 600s;
 +
        fastcgi_send_timeout 600s;
 +
        fastcgi_buffering off;
 +
 +
        #fastcgi_temp_path /data/owncloud/fastcgi_temp;
 +
 +
        gzip off;
 +
 +
        # Uncomment if your server is build with the ngx_pagespeed module
 +
        # This module is currently not supported.
 +
        #pagespeed off;
 +
 +
        index index.php;
 +
 +
        location = /robots.txt {
 +
            allow all;
 +
            log_not_found off;
 +
            access_log off;
 +
        }
 +
 +
        location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
 +
            deny all;
 +
            error_page 403 = /core/templates/403.php;
 +
        }
 +
 +
        location / {
 +
 +
            error_page 403 = /core/templates/403.php;
 +
            error_page 404 = /core/templates/404.php;
 +
 +
            rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
 +
            rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
 +
            rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
 +
 +
            rewrite ^(/core/doc[^\/]+/)$ $1/index.html;
 +
 +
            # The following rules are only needed with webfinger
 +
            rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
 +
            rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
 +
            rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
 +
            rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
 +
 +
            try_files $uri $uri/ /index.php;
 +
        }
 +
 +
        location ~ \.php(?:$|/) {
 +
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
 +
            include /opt/app/owncloud/config/fastcgi_params;
 +
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 +
            fastcgi_param PATH_INFO $fastcgi_path_info;
 +
            # fastcgi_param HTTPS on;
 +
            fastcgi_pass php-handler;
 +
        }
 +
 +
        # Optional: set long EXPIRES header on static assets
 +
        location ~* ^(/.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf))$ {
 +
            expires 30d;
 +
            access_log off;
 +
        }
 +
 +
    }
 +
}
 +
</syntaxhighlight>

Текущая версия на 14:14, 19 марта 2016

worker_processes 4;

error_log /opt/data/owncloud/log/nginx_error.log warn;

events {
    worker_connections  1024;
}

http {

    include ../nginx/conf/mime.types;

    upstream php-handler {
        server unix:/opt/app/owncloud/php/var/php5-fpm.sock;
    }

    server {
        listen 1082;
        server_name localhost;

        root /opt/app/owncloud/owncloud;
        client_max_body_size 10G;

        fastcgi_buffers 64 4K;
        fastcgi_read_timeout 600s;
        fastcgi_send_timeout 600s;
        fastcgi_buffering off;

        #fastcgi_temp_path /data/owncloud/fastcgi_temp;

        gzip off;

        # Uncomment if your server is build with the ngx_pagespeed module
        # This module is currently not supported.
        #pagespeed off;

        index index.php;

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
            deny all;
            error_page 403 = /core/templates/403.php;
        }

        location / {

            error_page 403 = /core/templates/403.php;
            error_page 404 = /core/templates/404.php;

            rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
            rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
            rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

            rewrite ^(/core/doc[^\/]+/)$ $1/index.html;

            # The following rules are only needed with webfinger
            rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
            rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
            rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
            rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

            try_files $uri $uri/ /index.php;
        }

        location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /opt/app/owncloud/config/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            # fastcgi_param HTTPS on;
            fastcgi_pass php-handler;
        }

        # Optional: set long EXPIRES header on static assets
        location ~* ^(/.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf))$ {
            expires 30d;
            access_log off;
        }

    }
}