I use an external API where a domain/key-pair is needed, and the domain-name doesn’t tolerate the port. So for my local development environment I would need to be able to use an URL without the port. I’m using Jetty.
Any ideas if / how this can be achieved?
(Some of what I’m writing might be obvious to you, but I prefer to be explicit)
When you say you want to have a URL without the port, that means that you actually want to run on port 80.
When a URL doesn’t include a port, the default port for the scheme is implied. The default port for
httpis 80, sohttp://www.google.com/is the same ashttp://www.google.com:80/So, to have your Jetty server available at
http://localhost/, you need to have it accessible on port 80.There are 3 broad options:
Actually start it on port 80. However, on most operating systems only the admin (root) user can start services on ports lower than 1024, so you would need to start/run jetty as
root. On OSX, that can be done by running Jetty withsudo. There are more complicated ways of doing this, but if you’re just running on your own desktopsudois the easiest. You can read about some of the other ways here: http://wiki.eclipse.org/Jetty/Howto/Port80Use operating system features to map requests for port 80 to the port you’re running Jetty on. On Linux (and other similar operating systems) you can use
ipchainsoriptables(the Port80 page I listed above describes these), on Mac OSXipfwcan do the sme thing. Here’s an example for running Tomcat on port 80 on OSX, exactly the same instructions will work for Jetty – In your case just change the8080to8090.Put another server (like Apache HTTPd) in front of Jetty. Run that server on port 80, and configure it to proxy requests through to your Jetty server. See: http://wiki.eclipse.org/Jetty/Howto/Configure_mod_proxy
Option #2 is probably what you want, but you’ll need to decide for yourself.