First, nginx anti-theft chain
#vi/usr/local/nginx/conf/vhost/test.com.conf
#/usr/local/nginx/sbin/nginx-t
#/usr/local/nginx/sbin/nginx-s Reload
#curl-E "http://www.baidu.com/1.txt"-x127.0.0.1:80-i test.com/1.gif//Hint 403
#curl-E "http://www.test.com/1.txt"-x127.0.0.1:80-i test.com/1.gif//Hint 200
Second, Nginx access control
#vi/usr/local/nginx/conf/vhost/test.com.conf
#/usr/local/nginx/sbin/nginx-t
#/usr/local/nginx/sbin/nginx-s Reload
#curl-E "http://www.baidu.com/1.txt"-x127.0.0.1:80-i test.com/admin//Access 127.0.0. 1 Normal
Match regular
#vi/usr/local/nginx/conf/vhost/test.com.conf
#/usr/local/nginx/sbin/nginx-t
#/usr/local/nginx/sbin/nginx-s Reload
#mkdir/data/wwwroot/test.com/upload//Create upload
#echo "1111" >/data/wwwroot/test.com/upload/1.php
#curl-x127.0.0.1:80 test.com/upload/1.php
Restrictions according to User_agent
#vi/usr/local/nginx/conf/vhost/test.com.conf
#curl-A "TOMATOAFDKDJK"-x127.0.0.1:80 test.com/upload/1.txt-i
If you want to ignore the case, you can add one after the ~ match symbol
number
if ($http _user_agent ~' Spider/3.0| Youdaobot| Tomato ')
{
return 403;
}
Three, Nginx parsing PHP related configuration
#vi/usr/local/nginx/conf/vhost/test.com.conf
#/usr/local/nginx/sbin/nginx-t
#/usr/local/nginx/sbin/nginx-s Reload
If the configuration file Fastcgi_pass Unix:/tmp/php-fcgi.sock, this path is not correct, will prompt 502 error, encountered 502 error first look at the errors log, and then to see if the configuration file is Fastcgi_pass unix:/tmp/ Php-fcgi.sock; This path is correct, if not correct, you need to view/usr/local/php-fpm/etc/php-fpm.conf in this configuration file sock path
#tail/usr/local/nginx/logs/nginx_error.log//View error log
If the/usr/local/php-fpm/etc/php-fpm.conf file defines the
Listen = 127.0.0.1:9000
So/usr/local/nginx/conf/vhost/test.com.conf the Fastcgi_pass in this configuration file unix:/tmp/php-fcgi.sock; need to be modified to Fastcgi_pass 127.0.0.1:9000;
Summarize 502 Error Resolution ideas:
First check nginx configuration/usr/local/nginx/conf/vhost/test.com.conf and PHP configuration/usr/local/php-fpm/etc/ Php-fpm.conf two files configured in the path to correspond, one configuration is the sock path, the other is configured to the same sock path, such as a configuration is 127.0.0.:9000, the other is also configured as 127.0.0.1:9000
Also note that in the/usr/local/nginx/conf/vhost/test.com.conf configuration file,
Fastcgi_param script_filename/data/wwwroot/test.com$fastcgi_script_name; This path corresponds to
Is the root/data/wwwroot/test.com in the configuration file;
502 The problem may also be that the PHP-FPM resource exhaustion causes the process to die and 502 errors are reported.
#vi/usr/local/php-fpm/etc/php-fpm.conf
Four, nginx agent
#cd/usr/local/nginx/conf/vhost/
#vi proxy.conf
#/usr/local/nginx/sbin/nginx-t
#/usr/local/nginx/sbin/nginx-s Reload
#curl ask.apelearn.com/robots.txt//robots.txt is a list of spider indexes
#curl-x127.0.0.1:80 ask.apelearn.com/robots.txt//Specify 127.0.0.1 can also access
Nginx anti-theft chain nginx access control Nginx parsing PHP-related configuration Nginx agent