poniedziałek, 2 lipca 2018

How to deploy Spring Boot, JHipster app to tomcat 8 and redirect domain to this app

This is, how to do it on Ubuntu 16 on AWS EC2.


  1. In /opt/tomcat/webapps/ create myApp folder [assuming you have myApp.war file to deploy]
  2. Redirect your domain to ip of your server.
  3. Redirect port 8080 to 80:
    sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 8080
    
    And make it persistent:
    sudo apt-get install iptables-persistent
    
  4. For now, copy to /opt/tomcat/webapps/myApp index.jsp from /opt/tomcat/webapps/ROOT.
  5. Change ownership of /opt/tomcat/webapps/myApp and its content to tomcat
  6. In /opt/tomcat/conf/server.xml, before </Engine> tag, add:
     <Host name="myApp.com" appBase="webapps" unpackWARs="false" autoDeploy="false">
    <Alias>www.myApp.com</Alias>
    <Context path="" docBase="/opt/tomcat/webapps/myApp" debug="0" privileged="true" />
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
    prefix="myApp_access_log." suffix=".txt" 
    pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false" />
    </Host>
    
  7. sudo systemctl restart tomcat
  8. Go to www.myApp.com and you should see tomcat home page, as it was copied in point 5.
  9. Copy myApp.war to /opt/tomcat/webapps/ - it will override existing files and deploy your app


Points 5-10 are necessarily, because tomcat seeing your app in server.xml Host section, trying to redeploy it, causing hang.

Brak komentarzy:

Prześlij komentarz