I have installed multiple tomcat instances in Ubuntu. I want to specify different URL to each tomcat instance. But I am not able to achieve desired result in case of multiple tomcat instances.
(Below URL is just to explain what I am trying to do)
Tomcat1: demo.mydomain.com/myapp: localhost:8080/myapp
Tomcat2: test.mydomain.com/myotherapp: localhost:8081/myotherapp
Modifying my Config Files after further search: I am trying to achieve it via AJP Port. So I did below Editing in my files:
Tomcat1 = demo
Tomcat2 = test
demo - server.xml
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
test- server.xml
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
workers.properties
worker.list=jk-status,demo,test
# Status worker for managing load balancer
worker.jk-status.type=status # setting type of jk-status' worker.
worker.demo.port=8009
worker.demo.host=localhost
worker.demo.type=ajp13
worker.test.port=8010
worker.test.host=localhost
worker.test.type=ajp13
Site enabled in /etc/apache2/sites-enabled
1_rewritehttp.conf
<VirtualHost *:80>
ServerName server
RewriteEngine On
RewriteRule (.*) http://server.mydomain.com%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:80>
ServerName server.mydomain.com
ServerAdmin webmaster@localhost
DocumentRoot /opt/www/
JkMount /jolokia-demo/* demo
JkMount /jolokia-test/* test
<Directory /opt/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName demo
RewriteEngine On
RewriteRule (.*) https://demo.mydomain.com%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:80>
ServerName demo.mydomain.com
RewriteEngine On
RewriteRule (.*) https://demo.mydomain.com%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:80>
ServerName test
RewriteEngine On
RewriteRule (.*) https://test.mydomain.com%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:80>
ServerName test.mydomain.com
RewriteEngine On
RewriteRule (.*) https://test.mydomain.com%{REQUEST_URI}
</VirtualHost>
3_demo.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName server.mydomain.com
DocumentRoot /opt/www/
<Directory /opt/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
JkMount /myapp/* demo
Alias /myapp/ "/opt/tomcat/demo/webapps/myapp/"
<Directory /opt/tomcat/demo/webapps/myapp/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
JkMount /manager/* demo
ErrorLog ${APACHE_LOG_DIR}/demo_error.log
CustomLog ${APACHE_LOG_DIR}/demo_access.log combined
SSLEngine on
SSLCertificateFile /usr/local/ssl/crt/public.cer
SSLCertificateKeyFile /usr/local/ssl/private/private.key
SSLCertificateChainFile /usr/local/ssl/crt/intermediate.cer
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
4_test.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName server.mydomain.com
DocumentRoot /opt/www/
<Directory /opt/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
JkMount /myotherapp/* test
Alias /myotherapp/ "/opt/tomcat/test/webapps/myotherapp/"
<Directory /opt/tomcat/test/webapps/myotherapp/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
JkMount /manager/* test
ErrorLog ${APACHE_LOG_DIR}/test_error.log
CustomLog ${APACHE_LOG_DIR}/test_access.log combined
SSLEngine on
SSLCertificateFile /usr/local/ssl/crt/public.cer
SSLCertificateKeyFile /usr/local/ssl/private/private.key
SSLCertificateChainFile /usr/local/ssl/crt/intermediate.cer
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
Now, The problem is I am able to access demo tomcat through URL. If I try to access test tomcat URL, it redirects to demo tomcat URL. I Tried accessing manager of both the tomcats and they are both pointing to demo tomcat manager, if I do below command then it redirects to test tomcat manager. I want to distinguish between both tomcat instances. I am missing something here. Any help would be appreciated.
a2dissite 3_demo.conf
Not able to find any proper way anywhere, So asked here. Please feel free to suggest- How to do it from scratch. Thanks in advance.