Apache + Tomcat: Using mod_proxy instead of AJP

前端 未结 3 1799
情书的邮戳
情书的邮戳 2020-12-02 07:34

Is there any way I connect Apache to Tomcat using an HTTP proxy such that Tomcat gets the correct incoming host name rather than localhost? I\'m using this directive in apac

3条回答
  •  孤街浪徒
    2020-12-02 08:33

    The settings you are looking for are:

    
      ServerName public.server.name
    
      ProxyRequests Off
      ProxyPreserveHost On
    
      
        Order deny,allow
        Allow from all
      
    
      ProxyPass / http://localhost:8080/
      ProxyPassReverse / http://localhost:8080/
    
    

    Note that we're using localhost as the proxy target. We can do this since we enable ProxyPreserveHost. The documentation states that

    It is mostly useful in special configurations like proxied mass name-based virtual hosting, where the original Host header needs to be evaluated by the backend server.

    which sounds exactly like what you are doing.

提交回复
热议问题