宝塔网设置伪静态进行隐藏php后缀名,nextcloud宝塔面板nginx伪静态-去除index.php
Loading...
> 一直在用nextcloud作为个人网盘用,前段时间电信赠送了一台vps,重新安装了nextcloud并使用了宝塔面板作为管理工具,安装方法和安装后的报警解决可以参考
CentOS7安装NextCloud
下载安装包wget https://download.nextcloud.com/server/releases/...
#### 修改宝塔PHP配置文件【非常重要,必须要改,否则不生效!!!】
- 路径:`/www/server/nginx/conf`
- 文件名:`enable-php-74.conf` 根据所使用php版本修改相对应文件
原配置文件内容:
```
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-74.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
```
在配置文件最后一行加上`fastcgi_param front_controller_active true;`
完整内容:
```
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-74.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
fastcgi_param front_controller_active true;
}
```
#### 添加nginx伪静态规则和一些其它安全配置
- 在宝塔面板的伪静态页面添加,也可直接在配置文件里面添加
```nginx
#(可选)添加如下header主要为了安全
add_header Strict-Transport-Security "max-age=63072000;";
#解析caldav和carddav
rewrite /.well-known/carddav /remote.php/dav permanent;
rewrite /.well-known/caldav /remote.php/dav permanent;
#静态资源重定向1
location ~* \/core\/(?:js\/oc\.js|preview\.png).*$ {
rewrite ^ /index.php last;
}
#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;
#静态资源重定向2,支持使用acme脚本在申请证书时对域名的验证
if ($uri !~* (?:\.(?:css|js|svg|gif|png|html|ttf|woff)$|^\/(?:remote|public|cron|status|ocs\/v1|ocs\/v2)\.php|^\/\.well-known\/acme-challenge\/.*$)){
rewrite ^ /index.php last;
}
}
#静态资源重定向3
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;
}
#caldav和carddav
rewrite /.well-known/carddav /remote.php/dav permanent;
rewrite /.well-known/caldav /remote.php/dav permanent;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
#(可选)为了支持user_webfinger app
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
#支持日历和联系人,建议加上
location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
#启动Gzip,不要删除ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
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;
#安全设置,禁止访问部分敏感内容
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;
}
#这部分吧,默认就有,不过有所不同,所以我合并了下,替换原来的就行
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on;
fastcgi_pass unix:/tmp/php-cgi-74.sock;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
# 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;
}
```
> 最后重启nginx,清除缓存,使用域名访问,发现index.php已经去掉,分享链接也没有index.php了。也可参考
>
> [官方文档](https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html)
最后修改:2020 年 08 月 28 日 03 : 59 PM
© 允许规范转载
赞赏
如果觉得我的文章对你有用,请随意赞赏
×Close
赞赏作者
扫一扫支付
支付宝支付
微信支付
宝塔网设置伪静态进行隐藏php后缀名,nextcloud宝塔面板nginx伪静态-去除index.php相关推荐
- nginx一招配置,帮你快速隐藏php后缀名
转载来源 : nginx一招配置,帮你快速隐藏php后缀名 :http://www.safebase.cn/article-260260-1.html 摘要: 现在很多人都喜欢用nginx作为Web服 ...
- hutool 读取扩展名文件_电脑隐藏/显示文件后缀名的方法
电脑隐藏/显示文件后缀名的方法好嗨哦!来了老弟! 有兄die跟小编说,为啥我重命名某个文件之后就打不开这个文件了.其实呀你在重命名文件时,系统会默认的把文件的后缀名也选中了,当你输入新的名称,也就把原 ...
- VSCode设置隐藏固定后缀名文件
前言 在用Angular CLI构建工程时,每次创建组件.服务等都会带有.spec.ts结尾的文件,这是用来单元测试用的.在平时构建工程时作用不大,在VSCode中显得非常繁琐. 在VSCode中设置 ...
- [转]URLRewrite隐藏.aspx后缀名的应用(转载+延伸)
本文转自:http://www.cnblogs.com/showker/archive/2010/01/11/1644062.html 前言:为什么转载这篇文章?因为它有思考有实践.最近因为业务的需要 ...
- nginx隐藏html后缀名,使用nginx重写“隐藏”.html文件扩展名
我通过nginx提供静态网站,我的目标是替换看起来像这样的网址: 同 关键是没有尾随斜线.我目前正在使用位置别名做类似的事情,但这很繁琐,因为它需要每个文件的位置块,并且它还附加一个尾部斜杠,因为ng ...
- 隐藏网站后缀名.aspx
method 1 首先添加全局应用程序Global.asax protected void Application_BeginRequest(Object sender, EventArgs e) ...
- 【杂谈与乱码】后缀名修改
[杂谈与乱码]修改文件后缀名 本人(ID:蒸发杰作)旗下所有文章均放弃版权,请任意使用.只是如果您觉得,看了我的文章,有所收获的话,不妨点个赞,写个评论.这是对我最大的支持. --杂谈与乱码,都是 ...
- Windows11修改文件后缀名的方法
Windows11修改文件后缀名的方法 最近买了一台新电脑:suface pro8 新电脑是真的香啊,但是目前发现一个问题,就是windows11的环境对文件后缀名的可修改性不太友好. 他的自定义是对 ...
- iis php扩展名,如何通过iis更改asp asp.net php后缀名
一些人热衷于修改网页的后缀名,例如把php的后缀名改为do,这样,index.php就变成了index.do,这样做的原因是为了让别人不知道你的网页使用的是什么语言,从而防止一些别有用心的人攻击.也有 ...
最新文章
- python安装第三方库-安装第三方模块
- mybaits十一:使用association分步查询
- centos7.0安装php,centos7.3安装php7.0
- Web开发模式(MVC设计模式)
- MySQL 使用自增ID主键和UUID 作为主键的优劣比较详细过程(从百万到千万表记录测试)...
- TiDB 在 Ping++ 金融聚合支付业务中的实践
- JavaAgent的使用总结
- pandas apply()函数传参,与解决TypeError: xxxx() takes 2 positional arguments but 3 were given报错
- newifi3 高恪魔改_newifi 3 四大路由器固件优劣分析
- 论文阅读:《Bridging the Gap in 3D Object Detection for Autonomous Driving》
- qt button clicked(bool) always false
- sentence_transformers 微调模型
- amcharts php,amcharts实现动态数据介绍
- Excel如何根据分组插入空行
- 自习室图书馆座位预约小程序 开题报告(基于微信小程序毕业设计题目选题课题)
- if test 用法
- C网络编程项目 图书借阅系统(一)
- SQL中的limit用法
- 世界十大最美历史遗迹
- 如果你看不懂KMP算法,一定要看看这个视频!!!!!!!!!!!虽然讲的慢,但是很详细!!!!