打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
owncloud Nginx Configuration
  • You need to insert the following code into your nginx config file.
  • The config assumes that ownCloud is installed in /var/www/owncloud andthat it is accessed via http(s)://cloud.example.com.
  • Adjust server_name, root, ssl_certificate andssl_certificate_key to suit your needs.
  • Make sure your SSL certificates are readable by the server (see Nginx HTTPSSL Module documentation).

Note

The following example assumes that your ownCloud is installed inyour webroot. If you’re using a subfolder you need to adjust the configurationaccordingly.

upstream php-handler {  server 127.0.0.1:9000;  #server unix:/var/run/php5-fpm.sock;  }server {  listen 80;  server_name cloud.example.com;  # enforce https  return 301 https://$server_name$request_uri;  }server {  listen 443 ssl;  server_name cloud.example.com;  ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;  ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;  # Add headers to serve security related headers  add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";  add_header X-Content-Type-Options nosniff;  add_header X-Frame-Options "SAMEORIGIN";  add_header X-XSS-Protection "1; mode=block";  add_header X-Robots-Tag none;  # Path to the root of your installation  root /var/www/owncloud/;  # set max upload size  client_max_body_size 10G;  fastcgi_buffers 64 4K;  # Disable gzip to avoid the removal of the ETag header  gzip off;  # Uncomment if your server is build with the ngx_pagespeed module  # This module is currently not supported.  #pagespeed off;  rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;  rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;  rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;  index index.php;  error_page 403 /core/templates/403.php;  error_page 404 /core/templates/404.php;  location = /robots.txt {    allow all;    log_not_found off;    access_log off;    }  location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){    deny all;    }  location / {   # The following 2 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;   rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;   try_files $uri $uri/ /index.php;   }   location ~ \.php(?:$|/) {   fastcgi_split_path_info ^(.+\.php)(/.+)$;   include fastcgi_params;   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;   fastcgi_param PATH_INFO $fastcgi_path_info;   fastcgi_param HTTPS on;   fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice   fastcgi_pass php-handler;   }   # Optional: set long EXPIRES header on static assets   location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {       expires 30d;       # Optional: Don't log access to assets         access_log off;   }  }

Note

You can use ownCloud over plain http, but we strongly encourage you touse SSL/TLS to encrypt all of your server traffic, and to protectuser’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;

Note

If you are using php-fpm please read Configuration notes to php-fpm

Suppressing Log Messages

If you’re seeing meaningless messages in your logfile, for example clientdenied by server configuration: /var/www/data/htaccesstest.txt<https://forum.owncloud.org/viewtopic.php?f=17&t=20217>_, add this section toyour Nginx configuration to suppress them:

 location = /data/htaccesstest.txt {    allow all;    log_not_found off;    access_log off;}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Debian8 Nginx MariaDB PHP7环境搭建ownCloud云存储
Zend Framework for RAR 服务器环境配置
Nginx的location配置规则梳理
nginx 正则表达式匹配入门篇
如何正确配置Nginx+PHP | Sina App Engine Blog
Nginx的泛域名绑定终于搞好了 - 火魔网
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服