Nginx 作反向代理时将客户端ip传递给Tomcat

来源:互联网 发布:爱普生l310清零软件 编辑:程序博客网 时间:2024/06/02 03:12

nginx.conf文件内

location / {    proxy_pass http://localhost:8080;    proxy_set_header X-Real-IP $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header Host $http_host;    proxy_intercept_errors on;}

server.xml文件内

 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"               prefix="access_log." suffix=".txt"               pattern="Remote User[ %{X-Forwarded-For}i %l %u %t ] Request[ &quot;%r&quot; ] Status Code[ %s ] Bytes[ %b ] Referer[ &quot;%{Referer}i&quot; ] Agent[ &quot;%{User-agent}i&quot; ]" />
0 0
原创粉丝点击