Guest User

nginx config for owncloud (nginx+php-fpm)

a guest
Dec 9th, 2015
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 2.81 KB | None | 0 0
  1. server {
  2.         listen   80; ## listen for ipv4; this line is default and implied
  3.         #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6
  4.  
  5.         root /var/www/cloud.example.com/webroot;
  6.         index index.php index.html index.htm;
  7.  
  8.         server_name cloud.example.com www.cloud.example.com;
  9.  
  10.         access_log /var/log/nginx/cloud.example.com-access.log;
  11.         error_log /var/log/nginx/cloud.example.com-error.log;
  12.  
  13.         # set max upload size
  14.         client_max_body_size 21G;
  15.         fastcgi_buffers 64 4K;
  16.  
  17.         # Disable gzip to avoid the removal of the ETag header
  18.         gzip off;
  19.  
  20.         rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
  21.         rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
  22.         rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
  23.  
  24.         error_page 403 /core/templates/403.php;
  25.         error_page 404 /core/templates/404.php;
  26.  
  27.         add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  28.         add_header X-Content-Type-Options nosniff;
  29.         add_header X-Frame-Options "SAMEORIGIN";
  30.         add_header X-XSS-Protection "1; mode=block";
  31.         add_header X-Robots-Tag none;
  32.  
  33.         location / {
  34.                 # The following 2 rules are only needed with webfinger
  35.                 rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  36.                 rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  37.  
  38.                 rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
  39.                 rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
  40.  
  41.                 rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
  42.  
  43.                 # First attempt to serve request as file, then
  44.                 # as directory, then fall back to displaying a 404.
  45.                 try_files $uri $uri/ /index.php;
  46.                 # Uncomment to enable naxsi on this location
  47.                 # include /etc/nginx/naxsi.rules
  48.         }
  49.  
  50.  
  51.         location ~ ^(.+?\.php)(/.*)?$ {
  52.                 fastcgi_pass unix:/var/run/php5-fpm-cloud.example.com.sock;
  53.                 fastcgi_index index.php;
  54.                 include fastcgi_params;
  55.                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
  56.                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  57.                 fastcgi_param HTTP_AUTHORIZATION $http_authorization;
  58.                 fastcgi_param PATH_INFO $fastcgi_path_info;
  59.                 fastcgi_param modHeadersAvailable true;
  60.  
  61.                 fastcgi_read_timeout 300;
  62.         }
  63.  
  64.         location = /robots.txt {
  65.                 allow all;
  66.                 log_not_found off;
  67.                 access_log off;
  68.         }
  69.  
  70.         location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
  71.                 deny all;
  72.         }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment