Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 4.00 KB | None | 0 0
  1. server {
  2.   listen 80;
  3.   listen [::]:80;
  4.   root /var/www/html/owncloud;
  5.   index index.php index.html index.htm;
  6.   server_name _;
  7.   location = /robots.txt {
  8.  
  9.     allow all;
  10.     log_not_found off;
  11.     access_log off;
  12.   }
  13.   # The following 2 rules are only needed for the user_webfinger app.
  14.   # Uncomment it if you're planning to use this app.
  15.   #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  16.   #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  17.   location = /.well-known/carddav {
  18.  
  19.     return 301 $scheme://$host/remote.php/dav;
  20.   }
  21.   location = /.well-known/caldav {
  22.  
  23.     return 301 $scheme://$host/remote.php/dav;
  24.   }
  25.   # set max upload size
  26.   client_max_body_size 512M;
  27.   fastcgi_buffers 8 4K; # Please see note 1
  28.   fastcgi_ignore_headers X-Accel-Buffering; # Please see note 2
  29.   # Disable gzip to avoid the removal of the ETag header
  30.   # Enabling gzip would also make your server vulnerable to BREACH
  31.   # if no additional measures are done. See https://bugs.debian.org/cgi-bin/bugrep$
  32.   gzip off;
  33.   # Uncomment if your server is build with the ngx_pagespeed module
  34.   # This module is currently not supported.
  35.   #pagespeed off;
  36.  
  37.   error_page 403 /core/templates/403.php;
  38.   error_page 404 /core/templates/404.php;
  39.   location / {
  40.  
  41.     rewrite ^ /index.php$uri;
  42.   }
  43.   location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
  44.  
  45.     return 404;
  46.   }
  47.   location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  48.  
  49.     return 404;
  50.   }
  51.   location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|ocm-provider/.+|core/templates/40[34])\.php(?:$|/) {
  52.  
  53.     include snippets/fastcgi-php.conf;
  54.     fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
  55.     fastcgi_split_path_info ^(.+\.php)(/.*)$;
  56.     include fastcgi_params;
  57.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  58.     fastcgi_param SCRIPT_NAME $fastcgi_script_name; # necessary for owncloud to detect the contextroot https://github.com/owncloud/core/blob/v10.0.0/lib/pr$
  59.     fastcgi_param PATH_INFO $fastcgi_path_info;
  60.     #fastcgi_param HTTPS on;
  61.     fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
  62.     fastcgi_param front_controller_active true;
  63.     fastcgi_read_timeout 180; # increase default timeout e.g. for long running carddav/ caldav syncs with 1000+ entries
  64.     #fastcgi_pass php-handler;
  65.     fastcgi_intercept_errors on;
  66.     fastcgi_request_buffering off; #Available since NGINX 1.7.11
  67.   }
  68.  
  69.   location ~ ^/(?:updater|ocs-provider|ocm-provider)(?:$|/) {
  70.  
  71.     try_files $uri $uri/ =404;
  72.     index index.php;
  73.   }
  74.  
  75.   # Adding the cache control header for js and css files
  76.   # Make sure it is BELOW the PHP block
  77.   location ~ \.(?:css|js)$ {
  78.  
  79.     try_files $uri /index.php$uri$is_args$args;
  80.     add_header Cache-Control "max-age=15778463" always;
  81.     # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)
  82.     # The always parameter ensures that the header is set for all responses, including internally generated error responses.
  83.     # Before enabling Strict-Transport-Security headers please read into this topic first.
  84.     # https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/
  85.     #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" always;
  86.     add_header X-Content-Type-Options nosniff always;
  87.     add_header X-Frame-Options "SAMEORIGIN" always;
  88.     add_header X-XSS-Protection "1; mode=block" always;
  89.     add_header X-Robots-Tag none always;
  90.     add_header X-Download-Options noopen always;
  91.     add_header X-Permitted-Cross-Domain-Policies none always;
  92.     # Optional: Don't log access to assets
  93.     access_log off;
  94.   }
  95.   location ~ \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map|json)$ {
  96.  
  97.     add_header Cache-Control "public, max-age=7200" always;
  98.     try_files $uri /index.php$uri$is_args$args;
  99.     # Optional: Don't log access to other assets
  100.     access_log off;
  101.   }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement