2

I'm using Apache (port 80) and GeoServer (port 8080) on Windows 7. I guess I need to set up a proxy if I want to use WFS, since they're on different ports.

My kind of silly question is, can I avoid it? If I re-set my website on GeoServer's www file, is everything going to work fine? Does GeoServer share the same characteristics with Apache?

If GeoServer's www file is a bad idea can you please help me set up a proxy? I never done it before, so if you have a link with an analytical tutorial, it would be great...

3
  • 1
    Can you provide a little more information? Is this an already-in-production site, or can you change URLs without much trouble? Are you familiar with Apache configuration?
    – BradHards
    Commented Jan 19, 2013 at 23:55
  • The whole system is on my laptop, still localhosts.I'm not so experienced with Apache config...
    – slevin
    Commented Jan 20, 2013 at 0:00
  • You can avoid using Apache HTTP server, and just run the Java server (Tomcat/Jetty). You can run these on port 80 if required, what's you requirement for Apache HTTP server?
    – nmtoken
    Commented Nov 14, 2019 at 19:55

2 Answers 2

2

I assume that your Apache is on port 80 and your Geoserver is on the same machine on port 8080.

I would suggest that you set up a reverse proxy on your Apache server. On my server I have set up Apache to resolve http://example.com/geoserver to http://example.com:8080/

That way I can just use the wms link as http://example.com/geoserver/wms & I don't need to use a proxy.cgi file.

You can see this Post on how to set Apache to route to another port using Virtual Hosts.

3
  • @ Devdatta I added to the Apache's httpd.conf file these lines LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule proxy_http_module modules/mod_proxy_http.so and at the end these ProxyPass /geoserver localhost:8080/geoserver ProxyPassReverse /geoserver localhost:8080/geoserver and I can now acceess geoserver's admin console through 80 port (using localhost/geoserver/web instead of localhost:8080/geoserver/web). I guess proxy is ok now?
    – slevin
    Commented Jan 20, 2013 at 19:41
  • @ Devdatta What about this line? OpenLayers.ProxyHost = '/cgi-bin/proxy.cgi?url='; Says I have to change the URL to point to my ProxyHost...But I did not add a proxy.cgi file at all...
    – slevin
    Commented Jan 20, 2013 at 19:53
  • You don't need that line at all. SInce now your geoserver is on the same domain as your appliation (i.e you are accessing your wms service as domain/geoserver/wms) you will not run into the crossdomain limitation Commented Jan 21, 2013 at 3:07
1

Almost any tool that you want to use with Apache or Geoserver will accept a port number as part of the URL. So for something like openlayers, a simple WFS example is shown at http://openlayers.org/dev/examples/wfs-filter.html

If you look at the source of that, you'll see a part that looks like:

            protocol: new OpenLayers.Protocol.WFS({
                url:  "http://demo.opengeo.org/geoserver/wfs",
                featureType: "tasmania_roads",
                featureNS: "http://www.openplans.org/topp"
            }),

For you, that is going to be something like:

            protocol: new OpenLayers.Protocol.WFS({
                url:  "http://localhost:8080/geoserver/wfs",
                featureType: "tasmania_roads",
                featureNS: "http://www.openplans.org/topp"
            }),

(where the bit after localhost:8080 depends on how you set up your geoserver, but should be fine if http://localhost:8080/geoserver brings up the admin console, as shown in http://docs.geoserver.org/stable/en/user/installation/windows/installer.html)

With that information, you should be able to avoid setting up a reverse proxy on Apache.

6
  • @ Brad What do you mean by "where the bit after localhost:8080 depends on how you set up your geoserver"? I thought that the url that I set was OK. And I need a proxy anyway because of the different ports. That's interesting (and I'm a rookie as you can see). Pls explain
    – slevin
    Commented Jan 20, 2013 at 0:19
  • Sorry: its hard for me to understand how you set up your GeoServer instance, and I don't understand what you do and don't know. GeoServer is very flexible, so there are some possibilities here. I'll expand the words above.
    – BradHards
    Commented Jan 20, 2013 at 0:24
  • No, it's my fault, I am sorry, let me rephrase. How can I check if the url I gave in WFS protocol, is valid?
    – slevin
    Commented Jan 20, 2013 at 0:46
  • You can do the procedure I put above (seeing if the management console comes up). To check WFS in particular, you can add "?request=getcapabilities" to the end of the URL, and check if that works in a browser or with curl or some other command line tool, (returning an XML file). So if localhost:8080/geoserver/wfs?request=getcapabilities works, it is the right URL.
    – BradHards
    Commented Jan 20, 2013 at 0:51
  • So, localhost:8080/geoserver actually does bring the admin console, but when I do a getcapabilities request, I get this on Chrome's console XMLHttpRequest cannot load localhost:8080/geoserver/wfs?request=getcapabilities. Origin localhost is not allowed by Access-Control-Allow-Origin.
    – slevin
    Commented Jan 20, 2013 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.