[GIS] GeoServer OpenLayers preview always points to localhost:8080

geoserveropenlayers-2

In GeoServer, when I go to Layer Preview/OpenLayers, I get a web page, but the HTML points to localhost:8080 (instead of a relative path) for its WMS requests, so I can only see previews on the server itself.

Is there a way to change the template or format of the OpenLayers preview, preferably without having to recompile anything?

Update

It looks like my question is being misunderstood, so I was probably not clear. Sorry about that.

Jetty indeed runs at port 8080, but that's fine.

The problem is that only with showing the OpenLayers preview.
Its JavaScript points to the WMS service at localhost:8080, even when you access the page from another machine.

I can't find any template on disk (I expected to find some .xslt or .ftl somewhere).

Update 2

I've reported this in the GeoServer issue tracker:
https://jira.codehaus.org/browse/GEOS-4930

Update 3

This question was asked in 2012. I gave up on trying to get this to work. After I've upgraded to a newer version of Geoserver, this started working.

Best Answer

The default GeoServer app engine / server is Jetty. In case you have not switched to the more powerful Tomcat, there is the procedure to change the port :

  • Shutdown Jetty server running $GEOSERVER/bin/shutdown.sh or $GEOSERVER/bin/shutdown.bat
  • Open file $GEOSERVER/etc/jetty.xml
  • Search line 8080 and change the default port.
  • Start Jetty

Here is my source for this procedure.

Edit : My answer was out of topic, so here is another one.

The preview function of GeoServer, using OpenLayers, is just a preview function, not a full featured OpenLayers application.

If you want to use the preview from distant client machines, you must log into the GeoServer administration and then go to preview. Just replace "locahost" with the IP address or DNS name of the server machine. If that don't work, your GeoServer installation could be broken, please provide details on the installation context (OS, versions).

If you want to consume your webservices from distant client machines, you should build an OpenLayers application with WMS/WFS layers connected to your GeoServer data feeds. See the examples on the OpenLayers doc.