Nginx Add_header


原文链接: Nginx Add_header

禁止浏览器缓存

    location ~.*\.(htm|html)$
    {
       #本地WEB目录,调整为实际的目录
       root D:/GoWorkSpace/goprojs/src/hr360proj/webapp; 
       # 禁止浏览器缓存
       add_header Cache-Control 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0';

}

直接获取客户端真实ip

location  /ip {
  # 默认是文件格式
  add_header  Content-Type 'text/html; charset=utf-8';

  set $realip $remote_addr;
  if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
    set $realip $1;
  }

  return 200 "$realip";
}
`