简体   繁体   中英

Jetty list on port 80 for application which would usually be on another port

I think my issue may be not knowing exactly what to look for (or the terminology), so hopefully this will serve to also help future people with similar questions.

I have a webapp running on Jetty, deployed using a .war in the webapps dir, lets say it is:

mydomain.com/foo

So the .war file is named "foo.war".

I also have some server which listens on another port, say port 9000. I would like to make this accessible through port 80, but Jetty is using that port. It is a HTTP server, but the port it listens on is 9000 (And I cannot change this).

Is it possible to have mydomain.com/baz relay data to and from localhost:9000 and then back to the client on port 80? Of course, this needs to be done through port 80 as to the outside world port 80 is the only one available, and jetty is already listening on port 80.

I suppose this would look like:

Client -> mydomain.com:80/baz -> mydomain.com:9000 -> mydomain.com:80/baz -> Client

Almost like an "iframe", only of course an iFrame would require the client to request mydomain.com:9000 which isn't open to the outside world.

You might find it straightforward to set up an Apache httpd which uses http proxying to provide a single set of URLs on port 80 to "clients", but which actually makes http requests to back end servers on non-standard ports behind the scenes.

Nginx can probably do this too.

Start here - http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM