0
votes

I am attempting to enable CORS access to a directory on my Apache2 web server. I enabled .htaccess file and added a line which is meant to enable CORS access to the directory.

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

After saving the .htaccess file with that line, I get a 500 internal server error when attempting to access the directory (http://williamgreen.hopto.org/audio/).

Any ideas? Is my header incorrect? Thank you.

Apache2 error.log:

[Thu Mar 09 15:02:15.118686 2017] [mpm_event:notice] [pid 2668:tid 547718139904] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Thu Mar 09 15:02:15.119080 2017] [core:notice] [pid 2668:tid 547718139904] AH00094: Command line: '/usr/sbin/apache2'
[Thu Mar 09 19:27:09.148771 2017] [mpm_event:notice] [pid 2668:tid 547718139904] AH00491: caught SIGTERM, shutting down
[Thu Mar 09 19:27:10.339942 2017] [mpm_event:notice] [pid 14385:tid 548172222464] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Thu Mar 09 19:27:10.340300 2017] [core:notice] [pid 14385:tid 548172222464] AH00094: Command line: '/usr/sbin/apache2'
[Thu Mar 09 19:39:47.583449 2017] [mpm_event:notice] [pid 14385:tid 548172222464] AH00491: caught SIGTERM, shutting down
[Thu Mar 09 19:39:47.776394 2017] [mpm_event:notice] [pid 14915:tid 548543827968] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Thu Mar 09 19:39:47.776776 2017] [core:notice] [pid 14915:tid 548543827968] AH00094: Command line: '/usr/sbin/apache2'
[Thu Mar 09 19:39:51.201462 2017] [core:alert] [pid 14919:tid 548512096688] [client 73.15.129.28:57278] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, referer: http://williamgreen.hopto.org/audio/Music/
[Thu Mar 09 19:39:51.204818 2017] [core:alert] [pid 14918:tid 548528873904] [client 73.15.129.28:57280] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, referer: http://williamgreen.hopto.org/audio/Music/
[Thu Mar 09 19:39:55.389791 2017] [core:alert] [pid 14918:tid 548520485296] [client 73.15.129.28:57279] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 09 19:40:02.264113 2017] [core:alert] [pid 14918:tid 548512096688] [client 73.15.129.28:57283] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 09 19:40:03.735693 2017] [core:alert] [pid 14919:tid 548503708080] [client 73.15.129.28:57284] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 09 19:40:04.183378 2017] [core:alert] [pid 14918:tid 548503708080] [client 73.15.129.28:57285] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 09 19:40:04.527274 2017] [core:alert] [pid 14919:tid 548520485296] [client 73.15.129.28:57286] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
[Thu Mar 09 19:40:04.846900 2017] [core:alert] [pid 14919:tid 548495319472] [client 73.15.129.28:57287] /var/www/html/audio/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

1
What are you seeing on the apache error log? - Cristian David
I'm adding to to my answer. I have swim practice so I have to leave. I don't have time to read it right now :( - www139
“Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration”… So the headers module isn’t enabled and you need to enable it in the system Apache config file or using a2enmod headers - sideshowbarker

1 Answers

3
votes

You dont have the headers module installed. With apache2, just run a2enmod headers and then sudo service apache2 restart and it will install the headers module automatically.