Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Open server manager and add new server roles:

Image Modified

Add latest versions of URL Rewrite and Application Request routing modules via Web Platform Installer from IIS Manager of website:

Image RemovedImage RemovedImage AddedImage Added

Open ports 80 and 443 in Windows Firewall for any incoming connections in case if it not opened.


Open Internet Information Services (IIS) Manager and configure Default Web Site:

1

Prerequisites

Before beginning installation get ready next things and settings:

  • MySQL 8.0 with created scheme and user with access to it (MySQL security group should allow inbound rules from new EC2 instance, default port 3306)

    Code Block
    languagesql
    -- Create schema script, character set and collation must be unchanged
    CREATE DATABASE `termweb_prod` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    CREATE USER 'termwebuser'@'%' IDENTIFIED BY 'sEcr3t!';
    GRANT ALL PRIVILEGES ON `termweb\_prod`.* TO 'termwebuser'@'%';
  • SMTP connection settings for sending emails

  • Elasticsearch connection settings (ES security group should allow inbound rules from new EC2 instance, default ports 9200 and 9300)

2

Launch new Windows Server 2019

  • For data storage will be enough 30-45GB depending on usage and log level

  • Update everything after successful login and reboot.

3

Configure Windows instance

Configure swap file

  • Calculate the swap space size (see):

    • 2 GB of RAM or less = swap size 2x the amount of RAM but never less than 32 MB

    • More than 2 GB of RAM but less than 32 GB = swap size 4 GB + (RAM – 2 GB)

    • 32 GB of RAM or more = swap size 1x the amount of RAM

  • For current example use 2GB swap size.

4

Install JDK

Download and install latest build of Open JDK Corretto 8 https://corretto.aws/downloads/latest/amazon-corretto-8-x64-windows-jdk.msi

5

Install Tomcat 9.0

Download and install Core version with Windows Service installer: https://downloads.apache.org/tomcat/tomcat-9/v9.0.41/bin/apache-tomcat-9.0.41.exe, don’t install manager, host manger, examples or documentation. Choose for example C:\tomcat folder for installation, or proceed with default.

Specify JDK instead of JRE as Java VM:

Leave other options with default values.

Configure tomcat via link “Configure Tomcat” in Start menu

  • Set Initial memory pool and Maximum memory pool to 1024MB for server with 2GB of RAM this will be enough

  • Add next java options to existing:

    Code Block
    languagebash
    -Dspring.config.name=termweb
    -Dspring.profiles.active=mysql,termweb3-search
    -Dfile.encoding=UTF-8
    -Duser.timezone=UTC
    -Dtermweb.home=C:\twhome
    -verbose:gc

Create TermWeb home folder

On previous step we pointed in Tomcat configuration TermWeb home folder as C:\twhome so lets create it.

Configure launch of TermWeb with operating system startup

  • Change startup type to Automatic or Automatic (Delayed Start)

6

Install and configure IIS

Expand
Code Block
Site name: winsetup.termweb.eu
Physical path: C:\inetpub\wwwroot\
Host name: winsetup.termweb.eu
Binding type: http

7

Configure IIS to proxy Tomcat

Enable proxy for server

Open Application Request Routing Cache for server by double clicking:

Open Server Proxy Settings and tick on Enable proxy, other settings may remain with default values:

Image RemovedImage Added

Setup rewrite rules

You can do it manually by editing URL Rewrite table for website:

But we suggest to put file web.config to root folder of web site (C:\inetpub\wwwroot).

Code Block
languagexml
<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Reverse Proxy REST API v4" stopProcessing="true">
                    <match url="^(api/.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy static js" stopProcessing="true">
                    <match url="^(js/.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy static custom" stopProcessing="true">
                    <match url="^(custom/.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy static layout" stopProcessing="true">
                    <match url="^(layout/.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy static tw4" stopProcessing="true">
                    <match url="^(tw4/.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy static app" stopProcessing="true">
                    <match url="^(app.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy static services" stopProcessing="true">
                    <match url="^(services/.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy login-openid" stopProcessing="true">
                    <match url="^(login-openid.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy login-oidc" stopProcessing="true">
                    <match url="^(login-oidc.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy login-saml" stopProcessing="true">
                    <match url="^(login-saml.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
                <rule name="Reverse Proxy login" stopProcessing="true">
                    <match url="^(login)" ignoreCase="false" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                    <conditions>
                        <add input="HTTP_HOST" pattern="localhost" ignoreCase="false" />
                    </conditions>
                </rule>

                <rule name="Angular Routes" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="./index.html" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

8

Configure encryption for your website

Pickup certificate from your IT department or get from any company. One of non commercial companies provides it for free: https://letsencrypt.org

9

Install TermWeb 4

Unpack distributive

  • Unpack termweb-4.0.6-0.zip

  • Unpack and move contents of termweb4.war (it’s regular zip archive) into tomcat webapps/ROOT folder (don’t forget to cleanup it first by removing all preinstalled files):

  • Unpack termweb-ui.zip archive and copy contents of dist folder into C:\inetpub\wwwroot.

Create and configure termweb.properties

  • Create and open for editing the unit file by running this command:
    C:\twhome\termweb.properties

  • To be able to start successfully TermWeb you need to configure at least this properties:

    Code Block
    languagejava
    base.url=https://winsetup.termweb.eu
    
    spring.datasource.driverClassName=com.mysql.jdbc.Driver
    spring.datasource.url=jdbc:mysql://mysqlserver:3306/termweb_prod?autoReconnect=true&useUnicode=true&character_set_server=utf8mb4&connectionCollation=utf8mb4_general_ci&useSSL=false
    spring.datasource.username=twuser
    spring.datasource.password=password
    
    email.smtp.server=smtpserver
    email.smtp.port=587
    email.smtp.user=user
    email.smtp.password=secr3t
    email.max.retry=3
    
    # Name of cluster
    termweb.elasticsearch.cluster.name=es-cluster
    termweb.elasticsearch.index-prefix=termweb4-winsetup
    termweb.elasticsearch.address=172.1.1.2
    termweb.elasticsearch.port=9200

Run and test

  • Restart IIS to see website
    Start tomcat, first launch will take about 2-5 minutes to create everything in database:
    Check tomcat logs for errors in file C:\tomcat\logs\catalina.out

  • Login as administrator with default credentials

10

Configure log rotation for Tomcat

To avoid tomcat logs grow without limits we need to configure logrotate for it. Major log file to rotate there is <tomcat_folder>/logs/catalina.out

11

Configure Monitoring for server status

We advise to configure tools on your choice which will monitor server status

12

Configure DB backups

Don’t forget to have DB backups on daily basis for example.

Table of Contents
printablefalse