Advertisement
Guest User

nextcloud.foo.tld.conf (Nextcloud web server)

a guest
Mar 22nd, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 7.69 KB | None | 0 0
  1. #
  2. # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html
  3. #
  4.  
  5. # https://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream
  6. upstream php-handler {
  7.     # https://nginx.org/en/docs/http/ngx_http_upstream_module.html#server
  8.     server 127.0.0.1:9000;
  9. }
  10.  
  11. # https://nginx.org/en/docs/http/ngx_http_map_module.html#map
  12. map $arg_v $asset_immutable {
  13.     "" "";
  14.     default ", immutable";
  15. }
  16.  
  17. # https://nginx.org/en/docs/http/ngx_http_core_module.html#server
  18. server {
  19.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#listen
  20.     listen 8082 default_server;
  21.     listen [::]:8082 default_server;
  22.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#server_name
  23.     server_name nextcloud.foo.tld;
  24.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#root
  25.     root /var/www/html;
  26.     # https://nginx.org/en/docs/ngx_core_module.html#include
  27.     include /etc/nginx/conf.d/common.conf;
  28.     # https://nginx.org/en/docs/ngx_core_module.html#include
  29.     include mime.types;
  30.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#types
  31.     types {
  32.         text/javascript js mjs;
  33.         application/wasm wasm;
  34.     }
  35.     # https://nginx.org/en/docs/http/ngx_http_index_module.html
  36.     index index.php index.html /index.php$request_uri;
  37.     ########## START nextcloud ##########
  38.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  39.     location = / {
  40.         if ( $http_user_agent ~ ^DavClnt ) {
  41.             # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  42.             return 302 /remote.php/webdav/$is_args$args;
  43.         }
  44.     }
  45.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  46.     location = /robots.txt {
  47.         # https://nginx.org/en/docs/http/ngx_http_access_module.html#allow
  48.         allow all;
  49.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found
  50.         log_not_found off;
  51.         # https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
  52.         access_log off;
  53.     }
  54.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  55.     location ^~ /.well-known {
  56.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  57.         location = /.well-known/carddav {
  58.             # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  59.             return 301 /remote.php/dav/;
  60.         }
  61.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  62.         location = /.well-known/caldav {
  63.             # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  64.             return 301 /remote.php/dav/;
  65.         }
  66.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  67.         location /.well-known/acme-challenge {
  68.             # https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
  69.             try_files $uri $uri/ =404;
  70.         }
  71.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  72.         location /.well-known/pki-validation {
  73.             # https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
  74.             try_files $uri $uri/ =404;
  75.         }
  76.         # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  77.         return 301 /index.php$request_uri;
  78.     }
  79.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  80.     location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) {
  81.         # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  82.         return 404;
  83.     }
  84.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  85.     location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
  86.         # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  87.         return 404;
  88.     }
  89.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  90.     location ~ \.php(?:$|/) {
  91.         # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite
  92.         rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;
  93.         # https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info
  94.         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  95.         # https://nginx.org/en/docs/stream/ngx_stream_set_module.html#set
  96.         set $path_info $fastcgi_path_info;
  97.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
  98.         try_files $fastcgi_script_name =404;
  99.         # https://nginx.org/en/docs/ngx_core_module.html#include
  100.         include fastcgi_params;
  101.         # https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param
  102.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  103.         fastcgi_param PATH_INFO $path_info;
  104.         fastcgi_param modHeadersAvailable true;
  105.         fastcgi_param front_controller_active true;
  106.         # https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_pass
  107.         fastcgi_pass php-handler;
  108.         # https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_intercept_errors
  109.         fastcgi_intercept_errors on;
  110.         # https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_request_buffering
  111.         fastcgi_request_buffering off;
  112.         # https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_max_temp_file_size
  113.         fastcgi_max_temp_file_size 0;
  114.     }
  115.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  116.     location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
  117.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
  118.         try_files $uri /index.php$request_uri;
  119.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
  120.         add_header Cache-Control "public, max-age=15778463$asset_immutable";
  121.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
  122.         add_header X-Frame-Options "SAMEORIGIN" always;
  123.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
  124.         add_header X-XSS-Protection "1; mode=block" always;
  125.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
  126.         add_header X-Content-Type-Options "nosniff" always;
  127.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
  128.         add_header Referrer-Policy "no-referrer" always;
  129.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
  130.         add_header X-Permitted-Cross-Domain-Policies "none" always;
  131.         # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
  132.         add_header X-Robots-Tag "noindex, nofollow" always;
  133.         # https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
  134.         access_log off;
  135.     }
  136.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  137.     location ~ \.woff2?$ {
  138.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
  139.         try_files $uri /index.php$request_uri;
  140.         # https://nginx.org/en/docs/http/ngx_http_headers_module.html#expires
  141.         expires 7d;
  142.         # https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
  143.         access_log off;
  144.     }
  145.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  146.     location /remote {
  147.         # https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return
  148.         return 301 /remote.php$request_uri;
  149.     }
  150.     # https://nginx.org/en/docs/http/ngx_http_core_module.html#location
  151.     location / {
  152.         # https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
  153.         try_files $uri $uri/ /index.php$request_uri;
  154.     }
  155.     ########## END nextcloud ##########
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement