We were hosting a site on github pages that needed to use cartodb.js and maps from our self-hosted cartodb server. Because github pages serves over https, there were mixed content errors when doing api calls to cartodb over http.
Adding ssl certificates to the nginx service on the docker host machine worked fine, but because the https traffic hitting nginx is just proxied to the cartodb services that are still running on http internally, the cartodb server is embedding http urls in some of its resources. This will lead to mixed content errors when using the cartodb app.
2 things had to be done to fix it:
- Edit cartodb/app/models/user/user_decorator.rb line 100, replace
base_url: public_url,
withbase_url: public_url.sub('http','https'),
This will update the user_data.base_url
global which cdb.js uses to build many of the api calls.
- Redirect all http requests to https in nginx. The fix above takes care of the api calls initiated from javascript, but many of the hyperlinks embedded in the app still use http. There is probably a way to edit something in the code to fix it, but redirecting http to https in nginx also does the trick. From http://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom:
server { listen 80; server_name my.domain.com; return 301 https://$server_name$request_uri; }