WebDAV, CORS

Status
Not open for further replies.

lletourn

Cadet
Joined
Aug 21, 2018
Messages
3
I'm wondering if there was an easy way to setup Cross Origin Resource Sharing (CORS) in WebDAV on FreeNAS (FreeNAS-11.1-U5)?

Long explanation:
I'm trying to use our FreeNAS server to host and serve HLS (m3u8) videos. For this to work I need to have CORS enabled. Is there an easy way to do this under FreeNAS?

The complicated way is to actually modify the webserver config files under FreeBSD, but I'd think there would be a simpler way.
The other solution would be to have a separate web server, which I think is overkill since the FreeNAS server already has all the parts...

Thank you.
Louis
 

lletourn

Cadet
Joined
Aug 21, 2018
Messages
3
I never got an official solution. We went ahead and changed the sources.

Since
Code:
/conf/base/etc/ix.rc.d/ix-apache
overwrites all config on boot, we needed to modify
Code:
/usr/local/libexec/nas/generate_webdav_conf.py
to add the CORS at every regeneration.

So in that file we modified the 'dav_config_pretext' variable and added our
Code:
<IfModule mod_headers.c>
			SetEnvIfNoCase Origin "http(s)?://(.*.<DOMAIN>.*)$" AccessControlAllowOrigin=$0
			Header add Access-Control-Allow-Origin %%{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
			Header add Access-Control-Allow-Credentials "true"
</IfModule>

<DOMAIN> == our allowed domain.

also make sure mod_headers is loaded. In our case it was.
 
Status
Not open for further replies.
Top