Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP and HTTPS port

Tags:

glassfish-3

I have created a J2EE application that runs on GlassFish, HTTPS enabled. When the user typed http: //www.mydomain.com:8080/app, it will be redirected to https: //www.mydomain.com:8181/app/login.

However, when I see in some of the websites, it can actually redirected to something like https: //www.mydomain.com/app/login (without the HTTPS port 8181). Does this means that the server is running both HTTP and HTTPS on port 80?

How to configure this on GlassFish 3.1?

like image 281
user851110 Avatar asked Jul 28 '11 13:07

user851110


People also ask

What are HTTP and HTTPS ports?

HTTP is unsecured while HTTPS is secured. HTTP sends data over port 80 while HTTPS uses port 443. HTTP operates at application layer, while HTTPS operates at transport layer. No SSL certificates are required for HTTP; with HTTPS, it is required that you have an SSL certificate and a CA signs it.

Is port 8080 HTTP or HTTPS?

If it's encrypted (https), it must be sent to 443/8443. If it's plain text (http) it must be sent to 80/8080.

Is 443 HTTP or HTTPS?

HTTPS (Hypertext Transfer Protocol Secure) is a secured HTTP version where all traffic is bind with strong encryption that passes through 443. This port is also connected with TCP protocol and creates a secure connection between the webpages and browser.

Can a port be both HTTP and HTTPS?

http runs on port 80, and https runs on TCP port 443. They can both be open at the same time, they can even serve different websites.


4 Answers

Non-root user should not use ports below 1024. It is better to do port forwarding from 80 to 8080 and 443 (https default) to 8181.

Execute this as root:

iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8181

Need to make this permanent:

iptables-save -c > /etc/iptables.rules
iptables-restore < /etc/iptables.rules

and call during startup, vi /etc/network/if-pre-up.d/iptablesload

#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0
like image 168
javadude Avatar answered Nov 09 '22 16:11

javadude


You can also configure it in the admin web gui under:
Configuration -> Server Config -> Network Config -> Network Listeners

like image 45
alexblum Avatar answered Nov 09 '22 16:11

alexblum


Just to give out more details on alexblum's answer, when you login into the Glassfish Admin panel, go to Configurations -> server-config -> Network Listeners in Network Config.

  1. Then click on New to add a new listener.
  2. On the new listener page, just select 80 as your port and put 0.0.0.0 as your IP.
  3. Select tcp as your Transport and use http-thread-pool as your Thread Pool
  4. Save and Restart your Glassfish instance.

Thats what worked for me anyways.

like image 23
janex Avatar answered Nov 09 '22 17:11

janex


The default port for HTTP is 80. When you access a URL: http://www.example.com/ you are connecting to www.example.com:80.

The default port for HTTPS is 443. When you access a URL: https://www.example.com/ you are connecting to www.example.com:443.

(See List of port numbers)

(See configuration of GlassFish to use other ports)

like image 42
Pindatjuh Avatar answered Nov 09 '22 16:11

Pindatjuh