在这里需要记录分发日志, 来分析后端每台WEB服务器处理的请求数目.
<pre name="code" class="python">http { log_format main ' $remote_user [$time_local] $http_x_Forwarded_for $remote_addr $request ' '$http_x_forwarded_for ' '$upstream_addr ' 'ups_resp_time: $upstream_response_time ' 'request_time: $request_time'; access_log logs/access.log main; server{} ... }在日志显示的信息为:
- [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.010 request_time: 0.011 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.16:8188 ups_resp_time: 0.006 request_time: 0.006 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.013 request_time: 0.013 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.17:8188 ups_resp_time: 0.003 request_time: 0.003 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.18:8188 ups_resp_time: 0.004 request_time: 0.004 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.012 request_time: 0.013 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.18:8188 ups_resp_time: 0.005 request_time: 0.005 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.16:8188 ups_resp_time: 0.011 request_time: 0.011 - [31/May/2013:00:01:03 -0700] - xxx.ip.addr.xxx GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.447 request_time: 0.759
全部配置文件nginx.conf.
# greatwqs@163.com Install on 2012-08-11 linux # user devwqs; # 2 intel(R) xeon(R) CPU worker_processes 4; worker_cpu_affinity 00000001 00000010 00000100 00001000; # error_log logs/error.log; # error_log logs/error.log notice; error_log logs/error.log error; pid logs/nginx.pid; # allow openning file nums worker_rlimit_nofile 25600; events { # linux 2.6 upper version. use epoll; worker_connections 51200; } 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"' # '"$upstream_addr"' '"$upstream_response_time"'; log_format main ' $remote_user [$time_local] $http_x_Forwarded_for $remote_addr $request ' '$http_x_forwarded_for ' '$upstream_addr ' 'ups_resp_time: $upstream_response_time ' 'request_time: $request_time'; access_log logs/access.log main; sendfile on; # tcp_nopush on; keepalive_requests 200; keepalive_timeout 20; gzip on; client_body_buffer_size 128k; client_body_timeout 60s; client_max_body_size 10m; # proxy_buffer_size 8k; # proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; # portal-cluster upstream portal-cluster { # http://192.168.100.15:8188/portal/ server 192.168.100.15:8188 weight=5 max_fails=5 fail_timeout=30s; # http://192.168.100.16:8188/portal/ server 192.168.100.16:8188 weight=5 max_fails=5 fail_timeout=30s; # http://192.168.100.17:8188/portal/ server 192.168.100.17:8188 weight=5 max_fails=5 fail_timeout=30s; # http://192.168.100.18:8188/portal/ server 192.168.100.18:8188 weight=5 max_fails=5 fail_timeout=30s; } # manage-cluster upstream manage-cluster { # http://192.168.100.25:8189/manage/ server 192.168.100.25:8189 weight=4 max_fails=5 fail_timeout=30s; # http://192.168.100.26:8189/manage/ server 192.168.100.26:8189 weight=6 max_fails=5 fail_timeout=30s; } # External Internet. server { listen 80; server_name www.huaxixiang.com; access_log logs/host.access.log main; location /portal/ { # root html; # index index.html index.htm; # nginx http header send to tomcat app. # proxy_set_header Host $host; # proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://portal-cluster; } # nginx status location /nginx_status { # copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/ stub_status on; access_log off; allow 192.168.100.100; #deny all; } location / { root html; index index.html index.htm; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # External Internet. server { listen 80; server_name manage.huaxixiang.com; access_log logs/host.access.log main; location /manage/ { proxy_pass http://manage-cluster; } location / { root html; index index.html index.htm; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
nginx status查看:
以上就介绍了Nginx 记录请求分发日志设置,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

PHP在电子商务、内容管理系统和API开发中广泛应用。1)电子商务:用于购物车功能和支付处理。2)内容管理系统:用于动态内容生成和用户管理。3)API开发:用于RESTfulAPI开发和API安全性。通过性能优化和最佳实践,PHP应用的效率和可维护性得以提升。

PHP可以轻松创建互动网页内容。1)通过嵌入HTML动态生成内容,根据用户输入或数据库数据实时展示。2)处理表单提交并生成动态输出,确保使用htmlspecialchars防XSS。3)结合MySQL创建用户注册系统,使用password_hash和预处理语句增强安全性。掌握这些技巧将提升Web开发效率。

PHP和Python各有优势,选择依据项目需求。1.PHP适合web开发,尤其快速开发和维护网站。2.Python适用于数据科学、机器学习和人工智能,语法简洁,适合初学者。

PHP仍然具有活力,其在现代编程领域中依然占据重要地位。1)PHP的简单易学和强大社区支持使其在Web开发中广泛应用;2)其灵活性和稳定性使其在处理Web表单、数据库操作和文件处理等方面表现出色;3)PHP不断进化和优化,适用于初学者和经验丰富的开发者。

PHP在现代Web开发中仍然重要,尤其在内容管理和电子商务平台。1)PHP拥有丰富的生态系统和强大框架支持,如Laravel和Symfony。2)性能优化可通过OPcache和Nginx实现。3)PHP8.0引入JIT编译器,提升性能。4)云原生应用通过Docker和Kubernetes部署,提高灵活性和可扩展性。

PHP适合web开发,特别是在快速开发和处理动态内容方面表现出色,但不擅长数据科学和企业级应用。与Python相比,PHP在web开发中更具优势,但在数据科学领域不如Python;与Java相比,PHP在企业级应用中表现较差,但在web开发中更灵活;与JavaScript相比,PHP在后端开发中更简洁,但在前端开发中不如JavaScript。

PHP和Python各有优势,适合不同场景。1.PHP适用于web开发,提供内置web服务器和丰富函数库。2.Python适合数据科学和机器学习,语法简洁且有强大标准库。选择时应根据项目需求决定。

PHP是一种广泛应用于服务器端的脚本语言,特别适合web开发。1.PHP可以嵌入HTML,处理HTTP请求和响应,支持多种数据库。2.PHP用于生成动态网页内容,处理表单数据,访问数据库等,具有强大的社区支持和开源资源。3.PHP是解释型语言,执行过程包括词法分析、语法分析、编译和执行。4.PHP可以与MySQL结合用于用户注册系统等高级应用。5.调试PHP时,可使用error_reporting()和var_dump()等函数。6.优化PHP代码可通过缓存机制、优化数据库查询和使用内置函数。7


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

SublimeText3汉化版
中文版,非常好用

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能