Run Glassfish without beeing root on Port 80
Hi,
if you try to run Glassfish on Port 80 without beeing root, that will fail.
It fails because of security reason. Non-root user cannot access ports under 1024.
First and often found way is to change you Iptables, which you can do like that.
|
1 2 3 |
sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8181 sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 sudo iptables-save |
But that did not really work for me. I did not want my wordpress links look like /wordpress:8080/someContent/
if i changed the admin settings to my default domain, that causes an endless loop…
so i choosed another way, called authbind.
Authbind lets you bind ports without beeing root. So we need to install authbind first and create a dummy file, to grant access to the user u would like to.
|
1 2 3 4 5 6 7 |
// first install authbind sudo apt-get install authbind // now create a dummy file which tells autbind who can access port 80 touch /etc/authbind/byport/80 chmod 500 /etc/authbind/byport/80 // change glassfish to your personal glassfish user :D chown glassfish /etc/authbind/byport/80 |
You now need to edit your /etc/init.d/glassfish file and add the auhtbind stuff:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#! /bin/sh export AS_JAVA=/usr/lib/jvm/java-6-sun GLASSFISHPATH=/home/glassfish/glassfish/bin case "$1" in start) echo "starting glassfish from $GLASSFISHPATH" sudo -u glassfish authbind --deep $GLASSFISHPATH/asadmin start-domain domain1 ;; restart) $0 stop $0 start ;; stop) echo "stopping glassfish from $GLASSFISHPATH" sudo -u glassfish authbind --deep $GLASSFISHPATH/asadmin stop-domain domain1 ;; *) echo $"usage: $0 {start|stop|restart}" exit 3 ;; esac |
We are finally done ![]()
What we need to do is to add a quite special entry to our domain.xml (or you do it within the admin panel)
Sorrily it will not work for IPv6 (see: Sun Bug Id 6771022 for more details)
So just open your domain.xml and add
|
1 |
<jvm-options>-Djava.net.preferIPv4Stack=true</jvm-options> |
That should do the trick!
Have Fun!
How to setup AWStats and Glassfish in Ubuntu MultipleBagFetchException