nginx apache集群后在nginx.conf 文件里这样设置
server {
搭建了一个服务器, 采用的是nginx + apache(多个) + php + mysql(两个) 多个apache负载均衡及后端mysql读写分离的服务器.
当然如果网站流量小的话 就完全没有必要了! 一是搭建起来麻烦,二也增加了维护成本! 当你网站流量达到一定级别不考虑也得考虑了.
当设定好 upstream 如下:
ngx_http_access_module
此模块提供了一个简易的基于主机的访问控制.
ngx_http_access_module 模块使有可能对特定IP客户端进行控制. 规则检查按照第一次匹配的顺序
一、nginx的几个命令参数
Nginx 安装后只有一个程序文件,本身并不提供各种管理程序,它是使用参数和系统信号机制对 Nginx 进程本身进行控制的。 Nginx 的参数包括有如下几个:
可以这样使用 /usr/local/nginx/sbin/nginx -参数
试过了,如果将盗链图片替换为图片貌似不行,就返回一个404 或403吧.
location ~* \.(gif|jpg|png|bmp|swf|flv)$ { valid_referers none blocked *.jiucool.com *.google.com *.xiaoguo.com *.zhuaxia.com; if ($invalid_referer) { return 403; } }
location /blog/{ autoindex off; set $wp_super_cache_file ”; set $wp_super_cache_uri $request_uri; if ( $request_method = POST ) { set $wp_super_cache_uri ”; } if ( $query_string ) { set $wp_super_cache_uri ”; } if ( $http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $wp_super_cache_uri ”; } if ( $wp_super_cache_uri ~ ^(.+)$ ) { set $wp_super_cache_file /blog/wp/wp-content/cache/wp_super_cache/$http_host/$1index.html; } if ( -f $document_root$wp_super_cache_file ) { rewrite ^(.*)$ $wp_super_cache_file break; } if (-f $request_filename) { expires 30d; break; } if (!-e $request_filename) { rewrite ^(.+)$ /blog/index.php?q=$1 last; } }
单独建一个server
server { server_name www.jiucool.com; rewrite ^(.*) http://jiucool.com$1 permanent; }
或者