6

I need to send a CORS header from my map server (QGIS mapserver) that use a fast cgi with Apache 2.4.* on the port 8080.

I configured the with a simple

<VirtualHost *:8080>
   [...]
   Header set Access-Control-Allow-Origin "*"
</VirtualHost>

and it works.

I want to set a proxy to avoid the specification of the port in the URL. I have configured another Virtualhost in the port 80:

<VirtualHost *:80>
    ProxyPass /cgi-bin/ http://localhost:8080/
    ProxyPassReverse /cgi-bin/ http://localhost:8080/

    # Is useful this?
    Header set Access-Control-Allow-Origin "*"
</VirtualHost>

but the header is not propagated. There is a solution?

Marcello Verona
  • 540
  • 1
  • 6
  • 10

2 Answers2

9

Add always

Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"

And, enable headers module

a2enmod headers
Rehmat
  • 2,121
  • 2
  • 24
  • 28
Stéphane
  • 161
  • 1
  • 6
6

This worked for me - using LocationMatch with ProxyPass and Header set:

<VirtualHost *:80>

  <LocationMatch "/cgi-bin/">
    ProxyPass http://localhost:8080/
    ProxyPassReverse http://localhost:8080/

    Header add Access-Control-Allow-Origin "*"
  </LocationMatch>

</VirtualHost>
konikoff
  • 101
  • 1
  • 5