阿里云SLB(负载均衡)获取真实ip地址, log_format配置
nginx.conf配置文件
#vim /usr/local/nginx/conf/nginx.conf log_format access '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" $http_x_forwarded_for ''"$upstream_addr" "$upstream_status" "$upstream_response_time" "$request_time"'; include /etc/nginx/conf.d/*.conf;duweixin.com.conf配置文件
#vim /etc/nginx/conf.d/duweixin.confserver{listen 80 default;server_name www.duweixin.net;index index.html;root /data/www/duweixin.net;location ~ .*\.do?${proxy_pass http://10.10.10.68:8099;}access_log /data/logs/www.duweixin.com.log access;}阿里云官網文檔:
IIS、apache、nginx日志中如何獲取用戶的真實IP?
https://help.aliyun.com/knowledge_detail/5973903.html?spm=5176.2020520129.111.9.Cah0In&pos=4
log_format日志參數說明:
$remote_addr 客戶端地址 例如:211.28.65.253
$remote_user 客戶端用戶名稱
$time_local 訪問時間和時區 例如:18/Jul/2012:17:00:01 +0800
$request 請求的URI和HTTP協議 例如:"GET /article-10000.html HTTP/1.1"
$http_host 請求地址,即瀏覽器中你輸入的地址(IP或域名) 例如:www.duweixin.net
192.168.100.100
$status HTTP請求狀態 例如:200
$upstream_status upstream狀態 例如:200
$body_bytes_sent 發送給客戶端文件內容大小 1547
$http_referer url跳轉來源 例如: http://www.duweixin.net/
$http_user_agent 用戶終端瀏覽器等信息 例如:"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; .NET4.0C;
$ssl_protocol SSL協議版本 例如:TLSv1
$ssl_cipher 交換數據中的算法 例如:RC4-SHA
$upstream_addr 后臺upstream的地址,即真正提供服務的主機地址 例如:10.10.10.100:80
$request_time 整個請求的總時間 例如:0.205
$upstream_response_time 請求過程中,upstream響應時間 例如:0.002
總結
以上是生活随笔為你收集整理的阿里云SLB(负载均衡)获取真实ip地址, log_format配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OSSIM中分布式消息队列应用
- 下一篇: 嵌入式linux开发环境搭建——Virt