Spring Boot with embedded Tomcat behind Apache proxy

前端 未结 7 1384
暖寄归人
暖寄归人 2020-12-08 09:51

We have a Spring Boot (Spring MVC) app with embedded Tomcat on a dedicated appserver behind an Apache SSL proxy.

The SSL port on the proxy server is 4433, forwarding

7条回答
  •  佛祖请我去吃肉
    2020-12-08 10:54

    I had exactly the same case using haproxy as load balancer with the below configuration, which worled for me. The only thing is the client IP is in request.getRemoteAddr() and not in "X-Forwarded-For" header

    frontend www
      bind *:80
      bind *:443 ssl crt crt_path
      redirect scheme https if !{ ssl_fc }
      mode http
      default_backend servers
    
    backend servers
      mode http
      balance roundrobin
      option forwardfor
      server S1 host1:port1 check
      server S2 host2:port2 check
      http-request set-header X-Forwarded-Port %[dst_port]
      http-request add-header X-Forwarded-Proto https if { ssl_fc }
    

    In application.properties:

     server.use-forward-headers=true
    

提交回复
热议问题