CentOS 7使用Nginx+MariaDB+PHP安装Nextcloud 13(3)

# Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~ \.(?:css|js|woff|svg|gif)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=15778463";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        # Before enabling Strict-Transport-Security headers please read into
        # this topic first.
        # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
        #
        # WARNING: Only add the preload option once you read about
        # the consequences in https://hstspreload.org/. This option
        # will add the domain to a hardcoded list that is shipped
        # in all major browsers and getting removed from this list
        # could take several months.
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        # Optional: Don't log access to assets
        access_log off;
    }

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets
        access_log off;
    }
}

检验一下配置的正确性之后就能用域名访问网盘了

nginx -t
systemctl restart nginx

常见错误

有可能你在访问页面时可以正常显示但是提示你“内部服务器错误”,若出现这个情况有两个可能:

Nginx对nextcloud文件夹的访问权限不够,使用如下操作重新给予权限

cd /var/www
mkdir -p nextcloud/data
chown nginx:nginx -R nextcloud/

SELinux未关闭
永久关闭SELinux需要编辑文件/etc/selinux/config,将SELINUX=enforcing修改为SELINUX=disabled,重启后生效
临时关闭SELinux只需要在shell中输入setenforce 0就可以临时关闭SELinux。

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f077cb0e727fa85bc9e11583e1cc7f55.html