当前位置:网站首页>laravel 宝塔安全配置
laravel 宝塔安全配置
2022-06-24 19:41:00 【王道长的编程之路】
一、网站目录安全:
防跨站攻击(open_basedir)
写访问日志
二、web配置文件
server{
listen 8080;
server_name laravel.test;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/laravel/public;
#错误页配置,可注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#PHP-INFO-START PHP引用配置,可以注释或修改
include enable-php-73.conf;
#URL重写,修改后将导致面板设置的伪静态规则失效
#include /vhost/rewrite/xiaobai.test.conf;
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md){
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\.(js|css)?$ {
expires 12h;
error_log off;
access_log /dev/null;
}
access_log /www/wwwlogs/xiaobai.test.log;
error_log /www/wwwlogs/xiaobai.test.error.log;
}
enable-php-73.conf
location ~ [^/]\.php(/|$){
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-73.sock;#php-cgi监听
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
# 常规配置
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;#php-fpm监听
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
pathinfo.conf
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
三、伪静态
/www/server/panel/vhost/rewrite/xiaobai.test.conf
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# 或
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
四、防盗链

边栏推荐
- go Cobra命令行工具入门
- 京东618会议平板排行榜公布,新锐黑马品牌会参谋角逐前三名,向国货老大华为学习
- Parental delegation mechanism
- Beijiafu (p+f) R2000 modified radar IP
- Data communication foundation - Ethernet port mirroring and link aggregation
- 剑指 Offer 42. 连续子数组的最大和
- Layer 2 and layer 3 forwarding principle based on VLAN
- 大厂面试必问:如何解决TCP可靠传输问题?8张图带你详细学习
- [postgraduate entrance examination English] prepare for 2023, learn list9 words
- [text data mining] Chinese named entity recognition: HMM model +bilstm_ CRF model (pytoch) [research and experimental analysis]
猜你喜欢

What kind of processor architecture is ARM architecture?

2022年高处安装、维护、拆除考试模拟100题及模拟考试

Are you afraid of being asked MySQL related questions during the interview? This 30000 word essence summary + 100 interview questions, and it's enough to hang the interviewer
Based on the codeless platform, users deeply participated in the construction, and digital data + Nanjing Fiberglass Institute jointly built a national smart laboratory solution

High level application of SQL statements in MySQL database (I)

关于某手滑块的一些更新(6-18,js逆向)

Servlet

Stop using it indiscriminately. This is the real difference between @validated and @valid!!!

Cases of addition, deletion, modification and search of C # learning for two years and C # import and export (de duplication)

2022-06-16 work record --js- judge the number of digits in string type digits + judge the number of digits in numeric type digits + limit the text length (display n words at most, exceeding...)
随机推荐
Servlet
find your present (2)
【Mongodb】READ_ ME_ TO_ RECOVER_ YOUR_ Data, the database is deleted maliciously
Cases of addition, deletion, modification and search of C # learning for two years and C # import and export (de duplication)
Wechat side: what is consistent hash? In what scenario? What problems have been solved?
Tech Talk 活动回顾|云原生 DevOps 的 Kubernetes 技巧
New, Huawei cloud Kaitian apaas
LeetCode Algorithm 剑指 Offer 52. 两个链表的第一个公共节点
cat写多行内容到文件
The usage difference between isempty and isblank is so different that so many people can't answer it
A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail
C#学习两年的增删改查和C#导入导出(去重)案例
Dynamic menu, auto align
Spark 离线开发框架设计与实现
Environment configuration | vs2017 configuring openmesh source code and environment
2022-06-10 work record --js- obtain the date n days after a certain date
EPICS记录参考2--EPICS过程数据库概念
结构体的内存对齐
Market trend report, technical innovation and market forecast of solar roof system in China
Research Report on market evaluation and investment direction of Chinese dermatology drugs (2022 Edition)