Problems with CORS and Reverse Proxy #1556
-
Hello, sorry for making this post, but I spend a full day trying to fix this issue and I have no idea left how to fix it. I am trying to run martin to server tiles for maputnik on my local device in podman containers. This is my compose: services:
postgis:
image: postgis/postgis:latest
# container_name: postgis-db
env_file:
- .env
ports:
- "${POSTGRES_PORT}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- db_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB} -p ${POSTGRES_PORT}"]
interval: 30s
timeout: 10s
retries: 5
martin:
image: ghcr.io/maplibre/martin
restart: unless-stopped
ports:
- 3000:3000
env_file:
- .env
depends_on:
- postgis
volumes:
- ./martin.yaml:/config/martin.yaml:ro
networks:
- db_network
- tile_server_network
command: ["--config", "/config/martin.yaml"]
nginx:
image: nginx:alpine
depends_on:
- martin
ports:
- "8080:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
networks:
- tile_server_network
maputnik:
image: ghcr.io/maplibre/maputnik:main
restart: unless-stopped
ports:
- 8888:80
# volumes:
# - ./style.json:/data/style.json
depends_on:
- martin
- nginx
networks:
- tile_server_network
volumes:
pgdata:
networks:
db_network:
tile_server_network:
Since martin does not support CORS headers, I figured out that it is not possible to just access the tiles from maputnik by setting the address to Next I added the nginx server as a reverse proxy:
Very basic config to set the When I query the server from the terminal, everything seems to be fine:
However, when I use it from the browser I get this header (notice the double Access-Control-Allow-Origin, does not matter if i write it with capital letter or not):
and this Can anybody help me with these issues? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
just a hunch (and simple to try out => lets try this first) - add_header 'Access-Control-Allow-Methods' 'GET';
- add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type';
+ add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
+ add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Keep-Alive,If-Modified-Since,Cache-Control,ETag'; the cors caching from https://serverfault.com/a/716283 might also be helpfull. |
Beta Was this translation helpful? Give feedback.
-
Thank you. That was indeed my error! |
Beta Was this translation helpful? Give feedback.
just a hunch (and simple to try out => lets try this first)
Could you try the following
the cors caching from https://serverfault.com/a/716283 might also be helpfull.