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

无忧云:服务器100G高防云服务器,bgpBGP云,洛阳BGP云服务器2核2G仅38.4元/月起

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

HoRain Cloud:国内特价物理机服务器,镇江机房,内地5线BGP接入,月付499元起

horain怎么样?horain cloud是一家2019年成立的国人主机商家,隶属于北京辰帆科技有限公司,horain持有增值电信业务经营许可证(B1-20203595),与中国电信天翼云、腾讯云、华为云、UCloud、AWS等签署渠道合作协议,主要提企业和个人提供云服务器,目前商家推出了几款特价物理机,都是在内地,性价比不错,其中有目前性能比较强悍的AMD+NVMe系列。点击进入:horain...

CUBECLOUD:香港服务器、洛杉矶服务器、全场88折,69元/月

CUBECLOUD(魔方云)成立于2016年,亚太互联网络信息中心(APNIC)会员,全线产品均为完全自营,专业数据灾备冗余,全部产品均为SSD阵列,精品网络CN2(GIA) CU(10099VIP)接入,与当今主流云计算解决方案保持同步,为企业以及开发者用户实现灵活弹性自动化的基础设施。【夏日特促】全场产品88折优惠码:Summer_2021时间:2021年8月1日 — 2021年8月8日香港C...

代理服务器网站为你推荐
51自学网站有哪些免费自学网湖南商标注册湖南商标注册怎么办理eset最新用户名密码ESET4.0最新用户名和密码伪静态什么是伪静态网站?伪静态网站有什么优势qq空间装扮qq空间怎么装扮雅虎天盾雅虎天盾、瑞星杀毒软件、瑞星防火墙、卡卡上网安全助手能同时使用吗?二层交换机什么是三层交换机?什么是二层叫交换机?有什么区别?网页打开很慢为什么打开网页很慢虚拟机软件下载谁有好用的虚拟机软件?三星s8什么时候上市大约什么时候买S8合适
域名网 域名注册使用godaddy a2hosting raksmart cpanel主机 个人空间申请 免费网页申请 便宜空间 下载速度测试 监控服务器 photobucket 德讯 永久免费空间 阿里云手机官网 攻击服务器 闪讯网 免费获得q币 e-mail byebyelove g6950 更多