Skip to content

Instantly share code, notes, and snippets.

@chriswhong
Created October 8, 2016 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriswhong/b0f221bc9594b9c2d419301dc800e691 to your computer and use it in GitHub Desktop.
Save chriswhong/b0f221bc9594b9c2d419301dc800e691 to your computer and use it in GitHub Desktop.
CartoDB in Docker Container https issues

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:

  1. Edit cartodb/app/models/user/user_decorator.rb line 100, replace base_url: public_url, with base_url: public_url.sub('http','https'),

This will update the user_data.base_urlglobal which cdb.js uses to build many of the api calls.

  1. 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; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment