2

I've set up an OSM Tile Server, as described here.

The server is up and running, and I'm able to open the default map page in the browser (http://tile-server-ip/osm/slippymap.html) and see the map.

However, when I try to pull map data from Tile Server on a page from another site using OpenLayers library, I get:

Image from origin 'http://tile-server-ip' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my-other-site' is therefore not allowed access.

So, I need to enable CORS on Tile Server.

I tried adding CORS to Apache configuration (/etc/apache2/sites-enabled/tileserver_site.conf):

Header set Access-Control-Allow-Origin "*"

, but that has no effect. I tried modifying /etc/renderd.conf and adding:

CORS=*

to [default] section, but that, again, has no effect.

So, the question is: how to enable CORS on Tile Server?

asked 04 Nov '14, 12:53

weekens's gravatar image

weekens
101126
accept rate: 0%

edited 04 Nov '14, 13:42

aseerel4c26's gravatar image

aseerel4c26 ♦
32.2k16239552


2 Answers:
4

The problem was actually solved by providing crossOrigin: null to OpenLayers OSM source:

layers: [
  new ol.layer.Tile({
    source: new ol.source.OSM({
      url: 'http://tile-server-ip/osm/{z}/{x}/{y}.png',
      crossOrigin: null
    })
  })
],
permanent link

answered 04 Nov '14, 13:38

weekens's gravatar image

weekens
101126
accept rate: 0%

0

I have the same problem. Solved in this way: Add Header set Access-Control-Allow-Origin "*" In /etc/apache2/conf-available/security.conf

and change the server name in tileservice_site.con ServerName map.MYSERVER.it ServerAlias a.map.MYSERVER.it b.map.MYSERVER.it c.map.MYSERVER.it

Hope this help...

permanent link

answered 12 Sep '15, 16:36

maurisor's gravatar image

maurisor
1
accept rate: 0%

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×175
×117
×1

question asked: 04 Nov '14, 12:53

question was seen: 18,484 times

last updated: 12 Sep '15, 16:37

powered by OSQA