标签:log lda cgi tool add html unix res off
nginx配置 server {
listen 80;
server_name laravel.hanye.com;
access_log /data/wwwlogs/laravel_access_nginx.log main;
error_log /data/wwwlogs/laravel_error_nginx.log;
root /home/hanye/laravel/public;
index index.html index.htm index.php;
location / {
root /home/qa/laravel/public;
index index.html index.htm index.php;
#CROS, 支持预发送请求
if ($request_method = ‘OPTIONS‘) {
add_header ‘Access-Control-Allow-Origin‘ ‘*‘ always;
add_header ‘Access-Control-Allow-Methods‘ ‘GET, POST, PUT, DELETE, PATCH,OPTIONS‘;
add_header ‘Access-Control-Allow-Headers‘ ‘X-Requested-With,Content-Type,Authorization‘;
add_header ‘Access-Control-Max-Age‘ 1728000;
add_header ‘Content-Type‘ ‘text/plain; charset=utf-8‘;
add_header ‘Content-Length‘ 0;
return 204;
}
##此处要注意写到location / 里面
if (!-e $request_filename){
rewrite (.*) /index.php last;
}
}
## 链接php
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/data/phpsock/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
error_page 405 =200 http://zz.1fangxin.net;
#CROS, 支持RESTFul模式
add_header ‘Access-Control-Allow-Origin‘ ‘*‘ always;
add_header ‘Access-Control-Allow-Methods‘ ‘GET, POST,PUT,DELETE,PATCH,OPTIONS‘;
add_header ‘Access-Control-Allow-Headers‘ ‘X-Requested-With,Content-Type,Authorization‘;
}
location ^~ /data/ {
return 403;
}
location ^~ /plus/ {
return 403;
}
location ^~ /install/ {
return 403;
}
location ^~ /templets/ {
return 403;
}
if ($http_user_agent ~ "FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|^$" )
{
return 403;
}
if ($http_user_agent ~* (Scrapy|HttpClient))
{
return 403;
}
location ~*(\/\/.*$) {
return 403;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
}
标签:log lda cgi tool add html unix res off
原文地址:https://blog.51cto.com/9025736/2521318