Linux CentOS VMware nginx anti-theft chain, nginx access control, Nginx parsing PHP-related configuration, Nginx Proxy

Source: Internet
Author: User

First, nginx anti-theft chain

The configuration is as follows and can be combined with the above configuration.

Location ~* ^.+\. (Gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls) $

{

Expires 7d;

Valid_referers none blocked Server_names *.test.com;

if ($invalid _referer)

{

return 403;

}

Access_log off;

}

Second, Nginx access control

Requirements: Access to the/admin/directory request, only a few IP access is allowed, configured as follows:

location/admin/

{

Allow 192.168.1.1101;

Allow 127.0.0.1;

Deny all;

}

mkdir/data/wwwroot/test.com/davery/

echo "Test,test" >/data/wwwroot/test.com/davery/1.html

-T &&-S reload

Curl-x127.0.0.1:80 Test.com/davery/1.html-i

Curl-x192.168.133.130:80 Test.com/davery/1.html-i

can match the regular

Location ~. * (abc|image)/.*\.php$

{

Deny all;

}

Restrictions according to User_agent

if ($http _user_agent ~ ' spider/3.0| Youdaobot| Tomato ')

{

return 403;

}

Deny all is the same as the return 403 effect

Three, Nginx parsing PHP related configuration

The configuration is as follows:

Vim/usr/local/nginx/conf/vhost/test.com.conf

Location ~ \.php$

{

Include Fastcgi_params;

Fastcgi_pass Unix:/tmp/php-fcgi.sock;

Fastcgi_index index.php;

Fastcgi_param Script_filename/data/wwwroot/test.com$fastcgi_script_name;

}

Fastcgi_pass used to specify the address or socket of the PHP-FPM listener

[Email protected] ~]# vi/data/wwwroot/test.com/3,php

Four, nginx agent

Cd/usr/local/nginx/conf/vhost

Vim proxy.conf//Add the following:

Server

{

Listen 80;

server_name ask.apelearn.com;

Location/

{

Proxy_pass http://121.201.9.155/;

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

}

}

Linux CentOS VMware nginx anti-theft chain, nginx access control, Nginx parsing PHP-related configuration, Nginx Proxy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.