How did I work with port:80 and https in my local environment..

.. with Tomcat?

1) Create a Java Keystore File using the keytool command.

Korays-MacBook-Pro:~ koraytugay$ keytool -genkey -alias koraytugay -keyalg RSA -keysize 2048 -keystore koraytugay.jks
Enter keystore password:  
Re-enter new password: 
What is your first and last name?
  [Unknown]:  Koray Tugay
What is the name of your organizational unit?
  [Unknown]:  Tugay 
What is the name of your organization?
  [Unknown]:  Tugay
What is the name of your City or Locality?
  [Unknown]:  Istanbul
What is the name of your State or Province?
  [Unknown]:  Abbasaga
What is the two-letter country code for this unit?
  [Unknown]:  TR
Is CN=Koray Tugay, OU=Tugay, O=Tugay, L=Istanbul, ST=Abbasaga, C=TR correct?
  [no]:  yes
 
Enter key password for <koraytugay>
 (RETURN if same as keystore password):  
Korays-MacBook-Pro:~ koraytugay$
Now we have a file called koraytugay.jks under /Users/koraytugay which is nice..

2) Configure web.xml in your Web Application

Just make sure you have this in web.xml:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Protected Context</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>

3) Configure server.xml in Tomcat

Important parts are as follows:
<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />
<Connector
       protocol="org.apache.coyote.http11.Http11NioProtocol"
       port="443" maxThreads="200"
       scheme="https" secure="true" SSLEnabled="true"
       keystoreFile="/Users/koraytugay/koraytugay.jks" keystorePass="myPassHere!@1"
       clientAuth="false" sslProtocol="TLS"/>
 
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

4) Test!

Start Tomcat with sudo and simply visit localhost..

So what is so special here? We simply visited localhost (on port 80 by default) and we were forced to use https (on port 443 by default).