geoserver / geoserver-cloud

Cloud Native GeoServer is GeoServer ready to use in the cloud through dockerized microservices.
http://geoserver.org/geoserver-cloud
Other
245 stars 73 forks source link

WMS not finding existing layers without first going to layer preview in the browser #506

Closed a-finocchiaro closed 1 week ago

a-finocchiaro commented 4 weeks ago

Hello!

I recently have come across an issue when running geoserver-cloud where the wms microservice is unable to locate layers that exist in the database. When attempting to access the layer at a url like this:

https://localhost:9090/geoserver-cloud/myworkspace/wms?&service=WMS&request=GetMap&layers=myworkspace%3AMyLayer&styles=&format=image%2Fpng&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A3857&bbox=-12210356.646387197,3443946.746416902,-12053813.612459157,3600489.7803449426

the WMS service will give an error like this:

org.geoserver.platform.ServiceException: Could not find layer myworkspace:MyLayer

However, WMS is able to find this layer if I navigate to it through the WebUI and go to Layer Preview and click on OpenLayers. Once I do that in a browser, that browser is then able to locate that layer on all subsequent requests (likely due to caching I'm guessing?) But, if I try to copy and paste the working URL from the layer preview to a new browser (or a private browser session), WMS gives the error above.

Also, this only seems to be an issue on Geoserver cloud. I have been using the Docker Compose configuration that Geoserver provides with no changes.

Thank you!

groldan commented 3 weeks ago

Hi, When you hit the wms url directly, the request comes an unauthenticated (anonymous), but when logged in in the webui, it'll come as the user you're logged in as.

The docker compose example you're using includes the Access Control List service, and there's no data access rule to allow anonymous users to access the WMS (or any other service/workspace/layer).

If you want anonymous to see all, in the webui go to "ACL Data Rules" and create a rule like the following:

image

a-finocchiaro commented 1 week ago

@groldan awesome, thank you so much for that information! I had a feeling it was something configuration-related that I was just missing.