Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGI variable "map" fails to validate. #691

Open
MrApe opened this issue Jan 4, 2024 · 8 comments
Open

CGI variable "map" fails to validate. #691

MrApe opened this issue Jan 4, 2024 · 8 comments

Comments

@MrApe
Copy link

MrApe commented Jan 4, 2024

I'm trying to get the mapserver up and running but get the following error:

msCGILoadMap(): Web application error. CGI variable "map" fails to validate.

Here is my compose file:

version: '3'
services:
  mapserver:
    image: camptocamp/mapserver
    ports:
      - 8081:80
    volumes:
      - $PWD/mapserver/:/etc/mapserver/
    restart: unless-stopped

The local mapserver dir contains the following:

mapserver
├── data
│   └── states_ugl.shp
└── mapserver.map

I changed the SHAPEPATH to use the data-directory:

SHAPEPATH      "data"
mapserver.map
# The annotated map file (sort of)
# Created by Pericles S. Nacionales for the MapServer tutorial
# 2005-04-08
# Maintained & enhanced since by Jeff McKenna, GatewayGeo
# 2023-04-19 Last updated
#
# MapServer map file uses the pound sign (#) to denote the start of a line
# comment--each line that needs to be commented has to be prepended with a "#".
#
# Map files begin with MAP keyword to signify the start of the map object.
# Well, the entire map file is THE map object.  Enclosed between MAP and END
# at the very bottom of this map file, are keyword/value pairs and other
# objects.
MAP
  IMAGETYPE      PNG
  EXTENT         -97.238976 41.619778 -82.122902 49.385620
  SIZE           400 300
  SHAPEPATH      "data"
  IMAGECOLOR     255 255 255

  # Layer objects are defined beneath the map object.  You need at least one
  # layer defined in your map file before you can display a map...  You can
  # define as many layers as you'd like.

  # Start of LAYER DEFINITIONS ---------------------------------------------
  LAYER # States polygon layer begins here
    NAME         "states"
    DATA         "states_ugl.shp"
    STATUS       OFF
    TYPE         POLYGON

    # The class object is defined within the layer object.  You can define as
    # many classes as you need (well, there are limits as with layers, but it's
    # senseless to define more than ten on a "normal" layer.  There are
    # situations, however, where you might have to do it.)
    CLASS
      NAME       "The Upper Great Lakes States"

      # There are styles in a class, just like there are classes in a layer,
      # just like there are layers in a map.  You can define multiple styles in
      # a class just as you can define multiple classes in a layer and multiple
      # layers in a map.
      STYLE
        COLOR        232 232 232
        OUTLINECOLOR 32 32 32
      END
    END
  END # States polygon layer ends here
  # End of LAYER DEFINITIONS -------------------------------

END # All map files must come to an end just as all other things must come to..

The query used is:

http://localhost:8081/cgi-bin/mapserv?map=/etc/mapserver/mapserver.map

What could be the problem?

@geographika
Copy link
Contributor

Is there a typo in the querystring?

http://localhost:8081/cgi-bin/mapserv?map=/etc/mapserver/mapserve.map

Shouldn't it be http://localhost:8081/cgi-bin/mapserv?map=/etc/mapserver/mapserver.map

@MrApe
Copy link
Author

MrApe commented Jan 4, 2024

Is there a typo in the querystring?

http://localhost:8081/cgi-bin/mapserv?map=/etc/mapserver/mapserve.map

Shouldn't it be http://localhost:8081/cgi-bin/mapserv?map=/etc/mapserver/mapserver.map

Thanks for helping out. It was actually just a type in the issue, not the original query. I double checked and fixed the original post.

@Zia-
Copy link

Zia- commented Oct 10, 2024

Hey Guys,
I am getting similar issue although I exactly followed above steps to spin up the server.

image

When doing curl

curl -X GET http://localhost:8081/cgi-bin/mapserv?map=/etc/mapserver/mapserver.map

image

Not sure what's going wrong and how to debug it. Just trying to setup a basic minimalistic version of it.
Any kind of help would be highly appreciated.

@sbrunner
Copy link
Member

And what did you get with this URL http://localhost:8081/?map=/etc/mapserver/mapserver.map?

@Zia-
Copy link

Zia- commented Oct 11, 2024

@sbrunner

mapserv(): Web application error. Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided.
This is what I get.

@sbrunner
Copy link
Member

MapServer 8 requires a configuration file, did you do that?
https://mapserver.org/mapfile/config.html

@Zia-
Copy link

Zia- commented Oct 14, 2024

@sbrunner : Below is my entire setup:

docker-compose.yaml:

version: '3'
services:
  mapserver:
    image: camptocamp/mapserver
    ports:
      - 8081:80
    volumes:
      - /mapserver/test/:/etc/mapserver/
    restart: unless-stopped

content inside /mapserver/test dir:

image

mapserver.map file:

# The annotated map file (sort of)
# Created by Pericles S. Nacionales for the MapServer tutorial
# 2005-04-08
# Maintained & enhanced since by Jeff McKenna, GatewayGeo
# 2023-04-19 Last updated
#
# MapServer map file uses the pound sign (#) to denote the start of a line
# comment--each line that needs to be commented has to be prepended with a "#".
#
# Map files begin with MAP keyword to signify the start of the map object.
# Well, the entire map file is THE map object.  Enclosed between MAP and END
# at the very bottom of this map file, are keyword/value pairs and other
# objects.
MAP
  IMAGETYPE      PNG
  EXTENT         -97.238976 41.619778 -82.122902 49.385620
  SIZE           400 300
  SHAPEPATH      "data"
  IMAGECOLOR     255 255 255

  # Layer objects are defined beneath the map object.  You need at least one
  # layer defined in your map file before you can display a map...  You can
  # define as many layers as you'd like.

  # Start of LAYER DEFINITIONS ---------------------------------------------
  LAYER # States polygon layer begins here
    NAME         "ne_10m_land"
    DATA         "ne_10m_land.shp"
    STATUS       OFF
    TYPE         POLYGON

    # The class object is defined within the layer object.  You can define as
    # many classes as you need (well, there are limits as with layers, but it's
    # senseless to define more than ten on a "normal" layer.  There are
    # situations, however, where you might have to do it.)
    CLASS
      NAME       "The Upper Great Lakes States"

      # There are styles in a class, just like there are classes in a layer,
      # just like there are layers in a map.  You can define multiple styles in
      # a class just as you can define multiple classes in a layer and multiple
      # layers in a map.
      STYLE
        COLOR        232 232 232
        OUTLINECOLOR 32 32 32
      END
    END
  END # States polygon layer ends here
  # End of LAYER DEFINITIONS -------------------------------

END # All map files must come to an end just as all other things must come to...

I'm running it using docker-compose up command.

This is what I see in my terminal:

image

Is there any other config file that I need to define? Am else I am missing in this minimalistic setup?

Thanks a lot!

@geographika
Copy link
Contributor

@Zia- there is a working Docker file using the camptocamp image at https://github.com/geographika/getting-started-with-mapserver/blob/main/workshop/exercises/docker-compose.yml
Docs at https://geographika.github.io/getting-started-with-mapserver/

It also has a config file https://github.com/geographika/getting-started-with-mapserver/blob/main/workshop/exercises/mapfiles/mapserver.conf referenced in the docker-compose file:

    environment:
      MAPSERVER_CONFIG_FILE: "/etc/mapserver/mapserver.conf"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants