配置文件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输入用户名和密码进入如图

ParkinHost:俄罗斯离岸主机,抗投诉VPS,200Mbps带宽/莫斯科CN2线路/不限流量/无视DMCA/55折促销26.4欧元 /年起

外贸主机哪家好?抗投诉VPS哪家好?无视DMCA。ParkinHost今年还没有搞过促销,这次parkinhost俄罗斯机房上新服务器,母机采用2个E5-2680v3处理器、128G内存、RAID10硬盘、2Gbps上行线路。具体到VPS全部200Mbps带宽,除了最便宜的套餐限制流量之外,其他的全部是无限流量VPS。ParkinHost,成立于 2013 年,印度主机商,隶属于 DiggDigi...

美国多IP站群VPS商家选择考虑因素和可选商家推荐

如今我们很多朋友做网站都比较多的采用站群模式,但是用站群模式我们很多人都知道要拆分到不同IP段。比如我们会选择不同的服务商,不同的机房,至少和我们每个服务器的IP地址差异化。于是,我们很多朋友会选择美国多IP站群VPS商家的产品。美国站群VPS主机商和我们普通的云服务器、VPS还是有区别的,比如站群服务器的IP分布情况,配置技术难度,以及我们成本是比普通的高,商家选择要靠谱的。我们在选择美国多IP...

美国高防云服务器 1核 1G 26元/月 香港/日本站群服务器 E5 16G 1600元/月 触摸云

触摸云国内IDC/ISP资质齐全商家,与香港公司联合运营, 已超8年运营 。本次为大家带来的是双12特惠活动,美国高防|美国大宽带买就可申请配置升档一级[CPU内存宽带流量选一]升档方式:CPU内存宽带流量任选其一,工单申请免费升级一档珠海触摸云科技有限公司官方网站:https://cmzi.com/可新购免费升档配置套餐:地区CPU内存带宽数据盘价格购买地址美国高防 1核 1G10M20G 26...

代理服务器网站为你推荐
怎么改ip怎么更改IP,怎么弄主页改不了为什么我电脑的主页改不了了?快速美白好方法脸部快速美白有什么好方法啊公章制作如何用photoshop制作公章二叉树遍历写出二叉树的先序遍历、中序遍历、后序遍历。pw美团网电话是什么pw伪静态伪静态和真静态哪种静态方式好arm开发板单片机开发板与ARM开发板有什么不同?网易公开课怎么下载网易公开课的视频该如何下载?开机滚动条谁会调开机的滚动条
成都主机租用 如何申请免费域名 希网动态域名 174.127.195.202 http500内部服务器错误 css样式大全 100m免费空间 空间出租 帽子云 howfile 怎么测试下载速度 免费全能主机 爱奇艺vip免费试用7天 百度云1t linux使用教程 个人免费主页 最漂亮的qq空间 移动服务器托管 英国伦敦 免费的域名 更多