Another approach could be to make your jetty listen to non 80 port and have
IP tables route your port 80 traffic to the non-80 port. Something like
this:

*/sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT
--to-port <custom_port_here>*



On Mon, Jul 9, 2012 at 7:50 AM, Dhillon, Inder <[email protected]>wrote:

> Actually I tried running jetty.sh both as root and non root user, but it
> gives same error.
>
> 2012-07-09 10:51:36.890:INFO:oejsh.ContextHandler:started
> o.e.j.w.WebAppContext{/briefcase,file:/tmp/jetty-0.0.0.0-80-briefcase.war-_briefcase-any-/webapp/},/opt/jetty-hightide-8.1.3.v20120416/webapps/briefcase.war
> log4j:WARN Continuable parsing error 49 and column 23
> log4j:WARN The content of element type "log4j:configuration" must match
> "(renderer*,throwableRenderer?,appender*,plugin*,(category|logger)*,root?,(categoryFactory|loggerFactory)?)".
> 2012-07-09 10:51:37.374:INFO:briefcase:Initializing Spring root
> WebApplicationContext
> 2012-07-09 10:51:44.772:INFO:oejsh.ContextHandler:started
> o.e.j.w.WebAppContext{/briefcase,file:/tmp/jetty-0.0.0.0-80-briefcase.war-_briefcase-any-/webapp/},/opt/jetty-hightide-8.1.3.v20120416/webapps/briefcase.war
> 2012-07-09 10:51:44.843:INFO:oejdp.ScanningAppProvider:Deployment monitor
> /opt/jetty-hightide-8.1.3.v20120416/contexts at interval 1
> 2012-07-09 10:51:44.882:WARN:oejuc.AbstractLifeCycle:FAILED
> [email protected]:80: java.net.SocketException: Permission
> denied
> java.net.SocketException: Permission denied
>         at sun.nio.ch.Net.bind(Native Method)
>         at
> sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126)
>         at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
>         at
> org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182)
>         at
> org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311)
>         at
> org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260)
>         at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>         at org.eclipse.jetty.server.Server.doStart(Server.java:273)
>         at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>         at
> org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
> 2012-07-09 10:51:44.883:WARN:oejuc.AbstractLifeCycle:FAILED
> org.eclipse.jetty.server.Server@46da3772: java.net.SocketException:
> Permission denied
> java.net.SocketException: Permission denied
>         at sun.nio.ch.Net.bind(Native Method)
>         at
> sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126)
>         at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
>         at
> org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182)
>         at
> org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311)
>         at
> org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260)
>         at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>         at org.eclipse.jetty.server.Server.doStart(Server.java:273)
>         at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>         at
> org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
> Exception in thread "main" java.net.SocketException: Permission denied
>         at sun.nio.ch.Net.bind(Native Method)
>         at
> sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126)
>         at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
>         at
> org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182)
>         at
> org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311)
>         at
> org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260)
>         at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>         at org.eclipse.jetty.server.Server.doStart(Server.java:273)
>         at
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
>         at
> org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1138)
>
> -----Original Message-----
> From: Thomas Becker [mailto:[email protected]]
> Sent: July-09-12 10:46 AM
> To: Dhillon, Inder
> Cc: JETTY user mailing list
> Subject: Re: [jetty-users] Error while running Jetty Server on port 80 as
> non root user
>
> And that's why it doesn't work. You need root privileges to open
> privileged ports like 80.
>
> The configuration you've done in jetty-setuid.xml will take care that
> jetty drops the privileges to the configured user after the listener socket
> has been opened. So you execute the jetty.sh script to start jetty as root.
> Jetty will start as root, open the privileged socket and then the jetty
> process will switch to the user given in jetty-setuid.xml.
> On 7/9/12 4:40 PM, Dhillon, Inder wrote:
> > I start at non root user.
> >
> > -----Original Message-----
> > From: Thomas Becker [mailto:[email protected]]
> > Sent: July-09-12 10:41 AM
> > To: JETTY user mailing list
> > Cc: Dhillon, Inder
> > Subject: Re: [jetty-users] Error while running Jetty Server on port 80
> > as non root user
> >
> > And you start it as root?
> >
> > On Mon Jul  9 16:33:52 2012, idhillon wrote:
> >> All,
> >>
> >> I was trying to setup jetty on port 80 but its giving exception
> >> saying permission denied as below. I have setup jetty to work with
> >> setuid and configured start.ini as follows:
> >>
> >> OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations,jta,j
> >> d
> >> bc,setuid
> >>
> >> (below as first configuration file in start.ini)
> >>
> >> etc/jetty-setuid.xml
> >>
> >> and jetty-setuid.xml file with username and group name of non root user.
> >>
> >> Also, I am starting using jetty.sh script under bin directory. I
> >> configured
> >> JETTY_PORT=80 in this script.
> >>
> >> I'll really appreciate if anyone can help me with this.
> >>
> >>
> >> Below is exception i am getting.
> >>
> >>
> >> 2012-07-03 15:29:02.411:INFO:oejdp.ScanningAppProvider:Deployment
> >> monitor /opt/jetty-hightide-8.1.3.v20120416/contexts at interval 1
> >> 2012-07-03 15:29:02.454:WARN:oejuc.AbstractLifeCycle:FAILED
> >> [email protected]:80: java.net.SocketException:
> >> Permission denied
> >> java.net.SocketException: Permission denied
> >>           at sun.nio.ch.Net.bind(Native Method)
> >>           at
> >>
> sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126)
> >>           at
> sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
> >>           at
> >>
> org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:182)
> >>           at
> >>
> org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:311)
> >>           at
> >>
> org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:260)
> >>           at
> >>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> >>           at org.eclipse.jetty.server.Server.doStart(Server.java:273)
> >>           at
> >>
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
> >>           at
> >> org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1215)
> >>           at java.security.AccessController.doPrivileged(Native Method)
> >>           at
> >> org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:113
> >> 8
> >> )
> >> 2012-07-03 15:29:02.455:WARN:oejuc.AbstractLifeCycle:FAILED
> >> org.eclipse.jetty.server.Server@66da9ea4: java.net.SocketException:
> >> Permission denied
> >> java.net.SocketException: Permission denied
> >>
> >>
> >> --
> >> View this message in context:
> >> http://jetty.4.n6.nabble.com/Error-while-running-Jetty-Server-on-port
> >> -
> >> 80-as-non-root-user-tp4958797.html
> >> Sent from the Jetty User mailing list archive at Nabble.com.
> >> _______________________________________________
> >> jetty-users mailing list
> >> [email protected]
> >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> > --
> > Thomas Becker <[email protected]>
> > www.webtide.com – Developer advice, services and support from the Jetty
> & CometD experts.
>
> --
> Thomas Becker <[email protected]>
> www.webtide.com – Developer advice, services and support from the Jetty &
> CometD experts.
>
>
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to