I've an Ubuntu 16.04 server with two NIC cards. Both of them are configured with static IP and set to different hosts. At this time, I've running Apache and glassfish through the same interface (only one of the cards), Apache listen on the port 80 and glassfish the 8080 (classic configuration).
Now I want to enable the second NIC in order to allow glassfish to listen the port 80. This way I'll have Apache listening port 80 of the first NIC and Glassfish the port 80 with the other card and different domain. However I can't accomplish that.
By the moment I've tried the following configurations but neither of them works:
I've been reading Glassfish documentation the last two or three days and didn't find the answer yet.
Both nic cards are on the same net, for example: 111.222.333.1 and the other 111.222.333.2
I didn't try with different sub nets maybe changing the second NIC IP to 111.222.444.2, however I don't have the necessary privileges to make those changes and before ask to the IT people on the company, and change other configurations, I'll like to know if someone of you have ever been on a similar scenario? does anyone have any idea? suggestions?
After several attempts I get with the right configuration.
Step 1
As the server have Apache and Glassfish servers, by default, apache configuration listen port 80 for all IPs, so is the first thing to change:
--/etc/apache2/ports.conf
change line "Listen 80" by "Listen ###.###.###.###:80" having ###... as the apache desired ip address
Then restart apache
/etc/init.d/apache2 restart
Step 2
Create http-listener for Glassfish on the port 80 for the second IP:
sudo ./asadmin create-http-listener --listeneraddress ###.###.###.### --listenerport 80 --acceptorthreads 16 --securityenabled=false --default-virtual-server server myListenerName
Step 3
If you already have Glassfish installed (like my case) it was already listening to the previous IP (apache one) but in 8080 port, in order to listen to the new IP, a new virtual server needs to be created:
./asadmin create-virtual-server --hosts my.domain.name --networklisteners myListenerName myservername
Step 4
At the time of http-listener "myListenerName" creation, it needed to be linked to a server, so the only available at that time was the default one: "server". So then manually update domain.xml in order to delete myListenerName from the network-listeners of server and add it to the virtual-server "myservername". At the end it looks like the above:
<virtual-server network-listeners="http-listener-1,http-listener-2" id="server"></virtual-server>
<virtual-server network-listeners="myListenerName" hosts="my.domain.nama" id="myservername"></virtual-server>
Step 5
Re start glassfish
./asadmin stop-domain domain1
./asadmin start-domain domain1
Step 6
Deploy any application to the new server
./asadmin deploy --virtualservers myservername /path/to/my.war
Step 7
Relax
I hope this info helps somebody!