nextcloud 去除 index.php 32.0.5版本可以用

PHP8.1版本 在conf目录里找到enable-php-81.conf   加入,

location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-81.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
fastcgi_param front_controller_active true;
}

 

nginx conf  mine.types  加入

application/javascript mjs;

 

nginx 网站配置文件加入

 

  • location ~ ^/.well-known/carddav {
    return 301 $scheme://$host/remote.php/dav;
    }

    location ~ ^/.well-known/caldav {
    return 301 $scheme://$host/remote.php/dav;
    }

    location /.well-known {
    rewrite ^/.well-known/webfinger /index.php/.well-known/webfinger last;
    rewrite ^/.well-known/nodeinfo /index.php/.well-known/nodeinfo last;
    rewrite ^/.well-known/(.*)$ /index.php/.well-known/$1 last;
    }

    # 处理 Nextcloud 的 ocm-provider 和 ocs-provider
    location ^~ /ocm-provider/ {
    try_files $uri $uri/ /index.php$request_uri;
    }

    location ^~ /ocs-provider/ {
    try_files $uri $uri/ /index.php$request_uri;
    }
    #webdav和其他所有请求重定向到index.php上
    location / {
    rewrite ^ /index.php$uri;
    rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
    rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
    rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
    rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
    }
    #静态资源重定向
    location ~* \.(?:png|html|ttf|ico|jpg|jpeg)$ {
    try_files $uri /index.php$uri$is_args$args;
    access_log off;
    }
    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
    try_files $uri/ =404;
    index index.php;
    }
    #安全设置,禁止访问部分敏感内容
    location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
    deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
    deny all;
    }
    location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
    deny all;
    }
    location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
    try_files $uri/ =404;
    index index.php;
    }
    # Adding the cache control header for js, css and map files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
    try_files $uri /index.php$request_uri;
    add_header Cache-Control “public, max-age=15778463”;
    add_header Referrer-Policy “no-referrer” always;
    add_header X-Content-Type-Options “nosniff” always;
    add_header X-Download-Options “noopen” always;
    add_header X-Frame-Options “SAMEORIGIN” always;
    add_header X-Permitted-Cross-Domain-Policies “none” always;
    add_header X-Robots-Tag “none” always;
    add_header X-XSS-Protection “1; mode=block” always;
    # Optional: Don’t log access to assets
    access_log off;
    }
    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
    try_files $uri /index.php$request_uri;
    # Optional: Don’t log access to other assets
    access_log off;
    }
    #mjs报错
    location ~* \.mjs$ {
    types { application/javascript mjs; }
    try_files $uri =404;
    }
    # WASM
    location ~* \.wasm$ {
    types {
    application/wasm wasm;
    }
    add_header Content-Type application/wasm;
    expires 7d;
    access_log off;
    }
    # otf
    location ~* \.otf$ {
    types {
    application/x-font-otf otf;
    font/opentype otf;
    }
    add_header Access-Control-Allow-Origin *;
    expires 30d;
    access_log off;
    }

发表评论

邮箱地址不会被公开。 必填项已用*标注

click to changeSecurity Code