Apache subdomain redirect into Tomcat

前端 未结 2 1704
甜味超标
甜味超标 2020-12-29 17:25

I\'m pretty new to Apache HTTP, and sysadmin-ing in general, so i have this question I have a domain (www.doamin.com) with an Apache listening to port 80, also I have an Apa

相关标签:
2条回答
  • 2020-12-29 17:34

    mod_jk is outdated. It is recomended to use mod_proxy (mod_proxy_http or mod_proxy_ajp) to connect forward requests to your apache server to the tomcat.

    1. define a virtual host in your apache config
    2. create a proxy directive that forwards your requests to tomcat

    Maybe this SO question give you some hints.

    You can define two virtual hosts (app1.domain.tld and app2.domain.tld) that have proxy definitions for their designated apps. Example for app1:

    <VirtualHost *:80>
        ServerName app1.domain.tld
        ProxyRequests Off
        ProxyPreserveHost On
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
        ProxyPass / http://localhost:8080/app1
        ProxyPassReverse / http://localhost:8080/app1
    </VirtualHost> 
    
    0 讨论(0)
  • 2020-12-29 17:39

    while Magomi was almost right,

    Presenting an exact way to do it.

    1. Add your subdomain to the DNS server

    2. integrate *mod_proxy* into httpf.conf :

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
    
    1. define two virtual hosts as following

      NameVirtualHost *:80

      <VirtualHost *:80>
          ServerName application.domain.com
          ProxyRequests Off
          ProxyPreserveHost On
          <Proxy *>
              Order deny,allow
              Allow from all
          </Proxy>
          ProxyPass / http://www.domain.com:8080/application/
          ProxyPassReverse / http://www.domain.com:8080/application/
      </VirtualHost>
      
      <VirtualHost *:80>
          DocumentRoot C:\<pathToApache>\www
          ServerName www.domain.com
      </VirtualHost>
      

    This will direct your site (www.domain.com) to your Apache HTTP server, and redirect all calls to Application to the Tomcat.

    Hope this Helps,

    -PK

    0 讨论(0)
提交回复
热议问题