I am being having a lot of issues deploying my war file on my VPS.
I have java-8 and tomcat-8. My server is an Apache/2.2.22 (Debian) and my HTTP is on port 80 and tomcat on 8080.
Currently if you go to www.sdfasdfasdf.com you get an empty directory listed. However if you go to www.asdfasdf.com:8080/resumesite you get my page that is running on tomcat.
Naturally what I am trying to do is have the user input www.asdfasdffd.com and not the port etc.
So far I have set up a virtual host at nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.sdfasdf.com
ServerAlias asdfasdf.com
ProxyPass /resumesite http://localhost:8080/resumesite
ProxyPassReverse /resumesite http://localhost:8080/resumesite
</VirtualHost>
In my server.xml file in tomcat I set up a <Host></Host>
<Host name="www.asdfasdffasdf.com" appbase="webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="resumesite_log." suffix=".txt"
pattern="common"/>
</Host>
With the above set up every single domain just lists my VPS's directory. At this point I do not know what to do.
My question is:
I want the user input www.asdfasdfasdf.com and not www.drew-jocham.com:8080/resumesite. I am attempting to do that, but like I said above, every single domain on my VPS just lists my servers whole directory with the above settings.
Also soon all the sites will be war files so there will be several domain names on the server. Some will be stored in tomcat webapps and some on my HTTP server on port 80 directly.
-------------------UPDATE 1-------------------
I went to nano /etc/apache2/sites-enabled/000-default.conf
added the below and restarted my tomcat server.
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.asdfasdfadf.com
ServerAlias asdfasdfadf.com
ProxyPass / http://localhost:8080/resumesite
ProxyPassReverse / http://localhost:8080/resumesite
</VirtualHost>
When I go to www.asdfasdfasdf.com still nothing rendered besides the below picture:
Also it adds www.asdfasdf/resumesite to EVERY domain on my VPS in which I have several, thus breaking them all.
However if I still go to www.asdfasdfasdf.com:8080/resumesite
it renders.
I read your question as you want the root of www.drew-jocham.com to give you the content of the TomCat service http://localhost:8080/resumesite
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.drew-jocham.com
ServerAlias drew-jocham.com
ProxyPass / http://localhost:8080/resumesite
ProxyPassReverse / http://localhost:8080/resumesite
</VirtualHost>
This Digital Ocean guide on reverse proxying is a good read on the subject and includes many more Apache config items you might find useful (like SSL) - https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
You need several options in your apache enabled, such as vhost_alias, proxy_ajp and mod_jk I think. Also your tomcat needs ajp enabled. Add this to your apache config:
ServerName "yourdomain.com:80"
ServerAlias "www.yourdomain.com"
ServerAlias "ipv4.yourdomain.com"
UseCanonicalName Off
<IfModule mod_jk.c>
JkMount /yourapp ajp13
JkMount /yourapp/* ajp13
JkMount / ajp13
JkMount /* ajp13
</IfModule>
Step1:- Add the following configuration in tomcat8 server.xml
<Host name="www.drew-jocham.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias>www.drew-jocham.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="$logprefix$." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="$RESUMESITEFOLDER$">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
</Host>
In the apache create a site with following
<VirtualHost www.drew-jocham.com>
ProxyPreserveHost On
ServerName www.drew-jocham.com
ServerAlias www.drew-jocham.com
Proxy Pass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
It above conf worked for my https://smartvocab.in
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With