'How to run glassfish 4 on port 80 instead of 8080? root access is not an issue

Did some google on it and the solution was to redirect using iptables or mod in apache? Since my application uses websockets the above solution breaks my websocket connectivity and I again have to connect to my websockets using port 8080. Is there any way that I can run the glassfish itself on port 80 so that my websockets also run on port 80 making easier for users behind corporate firewall to access the app since corparates may block 8080.

I have root access as well.



Solution 1:[1]

Go to glassfish4\glassfish\domains\domain1\config folder and here open domain.xml file and find tag

<network-listeners>
    <network-listener port="9999" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
</network-listeners>

in port attribute of <network-listeners> you can specify your port address whichever you want.

Solution 2:[2]

Here's another approach.

You can go to the admin console under port 4848 (I am using Glassfish 4.1.2) and navigate to "Configuration" > "server-config" > "HTTP Service" > "Http Listeners" > "http-listener-1" in the left hand navigation.

Click on the "http-listener-1" link in the main content window.

Change the port to desired number and save.

enter image description here

Restart Glassfish and run your application.

enter image description here

Solution 3:[3]

in some cases you have to change port before glassfish is started (in my case port 8080 is already in use by another instance) so answer 4 worked for me.

Solution 4:[4]

Following are simple steps to change the port number of Glassfish server
(GlassFish runs by default on port number 8080):

  1. Go to the folder where Glassfish is installed.
  2. Locate config folder which is as follows (Windows):
    • C:\Program Files\glassfish-3.0.1\glassfish\domains\domain1\config
  3. Open domain.xml using any text editor.
  4. Look for 8080 and change it to some other port number that doesn’t conflict with other port numbers (e.g. 8081).
  5. Save domain.xml.

Additional step if necessary:

  1. Now remove GlassFish from IDE and add it again so that IDE understands the new port number.
  2. Restart GlassFish, if it was already running.

Soruce Link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shinjin
Solution 2 BustedSanta
Solution 3 pikimota
Solution 4 Mehdi Rahimi