Since 2018 | : DIPP34593

JOIN US | PAY ONLINE | FAQ | SUPPORT

Domain Redirection To Tomcat Via Apache2 in Ubuntu

Domain Redirection To Tomcat Via Apache2 in Ubuntu

First, make sure mod_proxy is enabled by running:
Copy code
sudo a2enmod proxy
sudo a2enmod proxy_http
service apache2 restart

Then create a new virtual host in a file named /etc/apache2/sites-available/yourdomain.conf. Follow the steps below to configure it to point your domain to your Tomcat app:
Step 1: Copy 000-default.conf file (Location: /etc/apache2/sites-available)
Step 2: Rename the file to yourdomain.conf (Example: example.com.conf)
Step 3: Add the below lines within —– Below Lines —-:
bash
Copy code
# ————Lines Start —————–
ServerName yourdomainname.com
ServerAlias www.yourdomainname.com
ProxyRequests On
ProxyPass / http://localhost:portnumber/applicationname/
ProxyPassReverse / http://localhost:portnumber/applicationname/
ProxyPassReverseCookiePath /applicationname /
# ————– Lines End ———————–
# The last line is for maintaining the cookies.

Finally, enable the site and reload Apache:
Copy code
sudo a2ensite yourdomain.conf
sudo service apache2 reload