Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. upstream php-handler {
  2.     server 127.0.0.1:9000;
  3.     #server unix:/var/run/php/php7.0-fpm.sock;
  4. }
  5.  
  6. server {
  7.     listen 80;
  8.     listen [::]:80;
  9.     server_name cloud.example.com;
  10.     # enforce https
  11.     return 301 https://$server_name$request_uri;
  12. }
  13.  
  14. server {
  15.     listen 443 ssl http2;
  16.     listen [::]:443 ssl http2;
  17.     server_name cloud.example.com;
  18.  
  19.     # Use Mozilla's guidelines for SSL/TLS settings
  20.     # https://mozilla.github.io/server-side-tls/ssl-config-generator/
  21.     # NOTE: some settings below might be redundant
  22.     ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
  23.     ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;
  24.  
  25.     # Add headers to serve security related headers
  26.     # Before enabling Strict-Transport-Security headers please read into this
  27.     # topic first.
  28.     # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  29.     #
  30.     # WARNING: Only add the preload option once you read about
  31.     # the consequences in https://hstspreload.org/. This option
  32.     # will add the domain to a hardcoded list that is shipped
  33.     # in all major browsers and getting removed from this list
  34.     # could take several months.
  35.     add_header X-Content-Type-Options nosniff;
  36.     add_header X-XSS-Protection "1; mode=block";
  37.     add_header X-Robots-Tag none;
  38.     add_header X-Download-Options noopen;
  39.     add_header X-Permitted-Cross-Domain-Policies none;
  40.     add_header Referrer-Policy no-referrer;
  41.  
  42.     # Remove X-Powered-By, which is an information leak
  43.     fastcgi_hide_header X-Powered-By;
  44.  
  45.     # Path to the root of your installation
  46.     root /var/www/nextcloud/;
  47.  
  48.     location = /robots.txt {
  49.         allow all;
  50.         log_not_found off;
  51.         access_log off;
  52.     }
  53.  
  54.     # The following 2 rules are only needed for the user_webfinger app.
  55.     # Uncomment it if you're planning to use this app.
  56.     #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  57.     #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  58.  
  59.     # The following rule is only needed for the Social app.
  60.     # Uncomment it if you're planning to use this app.
  61.     # rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
  62.  
  63.     location = /.well-known/carddav {
  64.       return 301 $scheme://$host/remote.php/dav;
  65.     }
  66.     location = /.well-known/caldav {
  67.       return 301 $scheme://$host/remote.php/dav;
  68.     }
  69.  
  70.     # set max upload size
  71.     client_max_body_size 512M;
  72.     fastcgi_buffers 64 4K;
  73.  
  74.     # Enable gzip but do not remove ETag headers
  75.     gzip on;
  76.     gzip_vary on;
  77.     gzip_comp_level 4;
  78.     gzip_min_length 256;
  79.     gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  80.     gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
  81.  
  82.     # Uncomment if your server is build with the ngx_pagespeed module
  83.     # This module is currently not supported.
  84.     #pagespeed off;
  85.  
  86.     location / {
  87.         rewrite ^ /index.php$request_uri;
  88.     }
  89.  
  90.     location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
  91.         deny all;
  92.     }
  93.     location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
  94.         deny all;
  95.     }
  96.  
  97.     location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
  98.         fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
  99.         include fastcgi_params;
  100.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  101.         fastcgi_param PATH_INFO $fastcgi_path_info;
  102.         fastcgi_param HTTPS on;
  103.         #Avoid sending the security headers twice
  104.         fastcgi_param modHeadersAvailable true;
  105.         fastcgi_param front_controller_active true;
  106.         fastcgi_pass php-handler;
  107.         fastcgi_intercept_errors on;
  108.         fastcgi_request_buffering off;
  109.     }
  110.  
  111.     location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
  112.         try_files $uri/ =404;
  113.         index index.php;
  114.     }
  115.  
  116.     # Adding the cache control header for js, css and map files
  117.     # Make sure it is BELOW the PHP block
  118.     location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
  119.         try_files $uri /index.php$request_uri;
  120.         add_header Cache-Control "public, max-age=15778463";
  121.         # Add headers to serve security related headers (It is intended to
  122.         # have those duplicated to the ones above)
  123.         # Before enabling Strict-Transport-Security headers please read into
  124.         # this topic first.
  125.         # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
  126.         #
  127.         # WARNING: Only add the preload option once you read about
  128.         # the consequences in https://hstspreload.org/. This option
  129.         # will add the domain to a hardcoded list that is shipped
  130.         # in all major browsers and getting removed from this list
  131.         # could take several months.
  132.         add_header X-Content-Type-Options nosniff;
  133.         add_header X-XSS-Protection "1; mode=block";
  134.         add_header X-Robots-Tag none;
  135.         add_header X-Download-Options noopen;
  136.         add_header X-Permitted-Cross-Domain-Policies none;
  137.         add_header Referrer-Policy no-referrer;
  138.  
  139.         # Optional: Don't log access to assets
  140.         access_log off;
  141.     }
  142.  
  143.     location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
  144.         try_files $uri /index.php$request_uri;
  145.         # Optional: Don't log access to other assets
  146.         access_log off;
  147.     }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement