Porxy服务器配置
Proxy服务器(192.168.10.20)主要是负责终端客户的接入,为两台Squid缓存服务器提供均衡负载。现在我们就开始吧!
服务器网络配置
# ee /etc/rc.conf
ifconfig_lnc0="inet 192.168.10.20 netmask 255.255.255.0"
defaultrouter="192.168.10.10"
hostname="proxy.rd.bj"
# ee /etc/hosts
192.168.10.20 proxy.rd.bj
# ee /etc/resolv.conf
nameserver 192.168.10.40
# cd /usr/local/etc/nginx
# ee nginx.conf #更改配置文件
我更改后的配置文件如下:
user www www;
worker_processes 1;
error_log /var/log/nginx_error.log;
pid /var/run/nginx.pid;
events {
use kqueue;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx_access.log main;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
output_buffers 1 32k;
postpone_output 1460;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
upstream mysvr {
server 192.168.10.30:3128 weight=5;
server 192.168.10.31:3128 weight=5;
}
server {
listen 80;
server_name www.rd.bj;
charset gbk;
access_log /var/log/nginx_host.access.log main;
location / {
proxy_pass http://mysvr/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /nginx {
stub_status on;
access_log on;
auth_basic "NginxStatus";
auth_basic_user_file /usr/local/etc/nginx/htpasswd;
}
}
}
保存配置文件退出后,现在对刚才设置的文件进行验证。
# rehash
# nginx -t
2007/12/27 15:42:52 [info] 25243#0: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
2007/12/27 15:42:52 [info] 25243#0: the configuration file /usr/local/etc/nginx/nginx.conf was tested successfully
Very good,没问题了,我们在配置文件中还设置了查看Nginx的状态信息,所以,现在我们还必需生成一个htppasswd文件,这时候我们得用到 Apache的htpasswd 工具了, 我们这台代理服务器上没有Apache,现在只能依靠web服务器的了,去那生成一个过来。
生成htppasswd文件的方法:
#输入两次密码就完成了,然后把生成好的htpasswd文件拷贝到proxy的机器的/usr/local/etc/nginx目录下就行了。
如何在两台机器之间拷贝文件呢?scp出场了 ...
# scp /tmp/htpassswd root@192.168.10.20:/usr/local/etc/nginx
好了, 现在万事具备了,现在启动她吧!!!
# nginx
# ps -aux | grep nginx
root 804 0.0 3.4 4908 4288 ?? Ss 4:49PM 0:00.00 nginx: master process nginx (nginx)
www 805 0.0 13.8 18004 17404 ?? S 4:49PM 0:00.02 nginx: worker process (nginx)
root 807 0.0 0.3 536 416 p0 RL+ 4:49PM 0:00.00 grep nginx
本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕,E-mail:xinmeigg88@163.com
本文链接:http://www.dbeile.cn/news/183.html