站点限制 IP 访问

2019年6月28日

Nginx  在该站的nginx conf 配置 Server 中:

allow 221.226.186.102;
deny all;

例如 :

server {
        listen 80;
        server_name www.world-alive.xyz;
        index index.html index.htm index.php;
        root  /home/data/website/default;
        access_log /usr/local/nginx/logs/www.world-alive.xyz-access.log main;
        error_log /usr/local/nginx/logs/www.world-alive.xyz-error.log;

        allow 221.226.186.102;
        #allow 192.155.83.226;
        #allow 221.226.84.170;
        #allow 211.143.230.50;
        deny all;

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #rewrite /wp-admin$ $scheme://$host$uri/ permanent;

         location ~ .php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
                include        fastcgi_params;
                include        fastcgi/www.world-alive.xyz;
          }

        location /img/ {
                alias  /home/data/website/img/;
        }

        location /wp {
                if (-f $request_filename/index.php) {
                        rewrite (.*) $1/index.php;
                }
                if (!-f $request_filename){
                        rewrite ^/wp/(.*)$ /wp/index.php;
                }
        }

        location / {
                index  index.html index.htm;
        }

}
 

Apache 在 相应的站点配置文件的  <Directory  web path> ...  </Directory>

例如 :

<Directory "/home/data/website/default">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.php index.html
Order deny,allow
Deny From all
Allow From 221.226.186.102
</Directory>
 

 

 

 

没有评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注