设计思路:
把各个功能块儿分割成一个一个的配置文件,然后调用的时候需要什么就调用什么,这样可以重复使用;
我一般把配置文件存在conf目录下这样引用的时候就不用写目录了,直接写模块名称就好了当然你也可以都放到一个目录里面,然后加上目录路径也是可以的;
下面是自己整理的各常用模块代码:
php配置文件【php-fpm.conf】:
location ~ \.php$ { try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; include fastcgi_params; }使用方法:在虚拟主机配置中引入php-fpm.conf文件即可
include php-fpm.conf;
内容替换模块配置【public_rep.conf】:
sub_filter 过滤字符串1 ''; sub_filter 过滤字符串2 ''; sub_filter_once off;使用方法:在虚拟主机配置中引入public_rep.conf文件即可
include public_rep.conf;
拦截所有请求并返回同一页面【request_hold.conf】:
rewrite ^/(.*)$ /h5/index.html break; proxy_pass http://www.32e.top;使用方法:在虚拟主机配置的location / 中引入request_hold.conf文件即可
include request_hold.conf;
注释:
/h5/index.php 替换为你要返回结果的url路径
http://www.32e.top 替换为返回结果的域名
禁止搜索引擎收录【no_rotobs.conf】:
location =/robots.txt { default_type text/html; add_header Content-Type "text/plain; charset=UTF-8"; return 200 "User-Agent: *\nDisallow: /"; }使用方法:在虚拟主机配置中 中引入no_rotobs.conf文件即可
除特别注明外,本站所有文章均为博文家原创,转载请注明出处来自https://www.32e.top/services/linux/article-148.html
暂无评论