配置文件nokFreeBSD上搭建大型网站(Nginx代理服务器篇)ipr

代理服务器网站  时间:2021-03-02  阅读:()

七、 P orxy服务器配置

Proxy服务器 192.168.10.20主要是负责终端客户的接入为两台Squid缓存服务器提供均衡负载。现在我们就开始吧

服务器网络配置

#ee/etc/rc.confifconfig_lnc0="inet 192.168.10.20 netmask 255.255.255.0"de faultrouter="192.168.10.10"hostname="proxy.rd.bj"

#ee/etc/hosts

192.168.10.20 proxy.rd.bj

#ee/etc/resolv.confnameserver 192.168.10.40

网络环境配置好后我们开始安装Nginx在那里告诉我

#whereis nginxnginx: /usr/ports/www/nginx

#make config

#make showconfig #我的配置选项

===>The following configuration options are available for nginx-0.5.34:

DEBUG=off"Enable nginx debugging"

HTTP_MODULE=on"Enable HTTP module"

HTTP_ADDITION_MODULE=on"Enable http_addition module"

HTTP_DAV_MODULE=on"Enable http_webdav module"

HTTP_FLV_MODULE=on"Enable http_flv module"

HTTP_PERL_MODULE=on"Enable http_perl module"

HTTP_REALIP_MODULE=on"Enable http_realip module"

HTTP_REWRITE_MODULE=on"Enable http_rewrite module"

HTTP_SSL_MODULE=on"Enable http_ssl module"

HTTP_STATUS_MODULE=on"Enable http_stub_status module"

HTTP_SUB_MODULE=on"Enable http_sub module"

MAIL_MODULE=off"Enable IMAP4/POP3/SMTP proxy module"

MAIL_IMAP_MODULE=off"Enable IMAP4 proxy module"

MAIL_POP3_MODULE=off"Enable POP3 proxy module"

MAIL_SMTP_MODULE=off"Enable SMTP proxy module"

MAIL_SSL_MODULE=off"Enable mail_ssl module"

WWW=on"Enable html sample files"

===>Use'make config' to modify these settings

#make install clean

又开始等待了. . .

终于完了现在开始配置吧

#cd/usr/local/etc/nginx

#ee nginx.conf#更改配置文件

我更改后的配置文件如下user www www;worker_processes 1;error_lo g/var/lo g/nginx_error.lo g;pi d /var/run/nginx.pi d;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_us er_agent" "$http_x_forwarde d_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 44k;output_buffers 1 32k;postpone_output 1460;gzip on;gzip_min_length 1100;gzip_buffers 48k;gzip_types text/plain;

upstream mysvr {server 192.168.10.30:3128 weight=5;server 192.168.10.31:3128 weight=5;

}s erver {listen 80;s erver_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 432k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;

}location/nginx{stub_status on;access_log on;auth_basic "Nginx Status";auth_basic_user_file /usr/local/etc/nginx/htpasswd;

}

}

}

保存配置文件退出后现在对刚才设置的文件进行验证。

#rehash

#nginx-t

2007/12/2715:42:52[info]25243#0: the configuration file/usr/local/etc/nginx/nginx.conf syntax is ok2007/12/2715:42:52[info]25243#0: the configuration file/usr/local/etc/nginx/nginx.conf was tested successfully

Very good没问题了我们在配置文件中还设置了查看Nginx的状态信息所以现在我们还必需生成一个htppas swd文件这时候我们得用到Apache的htpas swd工具了 我们这台代理服务器上没有Apache现在只能依靠web服务器的了去那生成一个复制过来。

生成htppasswd文件的方法

#htpasswd-c/tmp/htpassswd nginx

输入两次密码就完成了然后把生成好的htpasswd文件拷贝到proxy的机器的/usr/local/etc/nginx目录下就行了。

如何在两台机器之间拷贝文件呢 s cp出场了. . .

#scp/tmp/htpassswd root@192.168.10.20:/usr/local/etc/nginx

好了 现在万事具备了现在启动她吧  

#nginx

#ps -aux|grep nginxroot 8040.03.449084288??Ss 4:49PM 0:00.00 nginx:master process nginx(nginx)www 8050.013.8 1800417404??S 4:49PM 0:00.02 nginx:worker process (nginx)root 8070.00.3 536 416 p0 RL+ 4:49PM 0:00.00 grep nginx

现在用浏览器查看一下N ginx的状态 http://192.168.10.20/nginx输入用户名和密码进入如图

无忧云-河南洛阳BGP,CEPH集群分布式存储,数据安全可靠,活动期间月付大优惠!

 无忧云怎么样?无忧云服务器好不好?无忧云值不值得购买?无忧云是一家成立于2017年的老牌商家旗下的服务器销售品牌,现由深圳市云上无忧网络科技有限公司运营,是正规持证IDC/ISP/IRCS商家,主要销售国内、中国香港、国外服务器产品,线路有腾讯云国外线路、自营香港CN2线路等,都是中国大陆直连线路,非常适合免备案建站业务需求和各种负载较高的项目,同时国内服务器也有多个BGP以及高防节点...

CYUN(29元/月)美国、香港、台湾、日本、韩国CN2,续费原价

关于CYUN商家在之前有介绍过一次,CYUN是香港蓝米数据有限公司旗下的云计算服务品牌,和蓝米云、蓝米主机等同属该公司。商家主要是为个人开发者用户、中小型、大型企业用户提供一站式核心网络云端部署服务,促使用户云端部署化简为零,轻松快捷运用云计算。目前,CYUN主要运营美国、香港、台湾、日本、韩国CN2线路产品,包括云服务器、站群服务器和独立服务器等。这次看到CYUN夏季优惠活动发布了,依然是熟悉的...

Atcloud:全场8折优惠,美国/加拿大/英国/法国/德国/新加坡vps,500g大硬盘/2T流量/480G高防vps,$4/月

atcloud怎么样?atcloud刚刚发布了最新的8折优惠码,该商家主要提供常规cloud(VPS)和storage(大硬盘存储)系列VPS,其数据中心分布在美国(俄勒冈、弗吉尼亚)、加拿大、英国、法国、德国、新加坡,所有VPS默认提供480Gbps的超高DDoS防御。Atcloud高防VPS。atcloud.net,2020年成立,主要提供基于KVM虚拟架构的VPS、只能DNS解析、域名、SS...

代理服务器网站为你推荐
中国联通话费查询中国联通话费查询拨打什么号伪装微信地理位置微信朋友圈怎么使用伪装地理位置公章制作如何制作公章硬盘人硬盘是指什么人开机滚动条怎么减少开机滚动条?mate8价格华为mate8市场价多少2012年正月十五2012年正月十五 几月几号宕机人们说的宕机是什么意思小米手柄小米手柄和飞智手柄哪个好?rewritebase为什么我写.htaccess这个 rewriterule 进入死循环了,高手帮忙修改
北京vps主机 linode日本 便宜域名 美元争夺战 主机屋免费空间 免费网络电视 嘉洲服务器 个人免费空间 天互数据 北京双线机房 台湾谷歌 双12 彩虹云 无限流量 www789 免费php空间 云服务是什么意思 国内空间 重庆服务器 双11促销 更多