user3851283
user3851283

Reputation: 347

How to Enable CORS for Apache httpd server? (Step-By-Step Process)

I was wondering if anybody can help me set up CORS on my Apache web server. I would appreciate a step-by-step process because many sites online are telling me different things. Like what do I need to do on my httpd.conf or ssl.conf files, where to put my .htaccess file, etc.

Upvotes: 11

Views: 23318

Answers (2)

The above answer is correct and put Inside the httpd.conf. This should be changed to whatever you set Document Root.

On Ubuntu, httpd.conf is located in the directory /etc/apache2. apache2.conf is also located in /etc/apache2.

On CENTOS 6 httpd.conf in the path /etc/httpd/conf/httpd.

<Directory "/var/www/html">
        Header set Access-Control-Allow-Origin "*"
</Directory>

Upvotes: 10

Kevin Seifert
Kevin Seifert

Reputation: 3582

# edit your conf/httpd.conf file.  Verify that the headers module is loaded
LoadModule headers_module modules/mod_headers.so

# to whitelist every origin, use
Header set Access-Control-Allow-Origin "*"

More info: http://enable-cors.org/server_apache.html

Upvotes: 9

Related Questions