sverhoeven / docker-cartodb

Dockerized CartoDB
BSD 3-Clause "New" or "Revised" License
147 stars 117 forks source link

Trying carto over https:// but ui keeps redirecting to http:// #68

Closed aarontract closed 5 years ago

aarontract commented 5 years ago

I am trying to get cartodb to run over https but the front end keeps getting redirect to http://

I can load the login page over https:// but as soon as I login or refresh the page I get redirect to http://

I can request assets over https fine, load tiles, access the API, but if I do anything in the UI I get a 302 redirect, not sure what I have done wrong.

I have installed nginx on the host machine running a reverse proxy in front of the docker container and am using a Let's encrypt certificate (on the host machine). So there are two instances of nginx running.

I have updated: /cartodb/config/app_config.yml. /Windshaft-cartodb/config/environments/development.js and /cartodb/app/models/user/user_decorator.rb (line 100, replace base_url: public_url, with base_url: public_url.sub('http','https')

I used this as a guide: https://github.com/sverhoeven/docker-cartodb/issues/28

the nginx rule looks like this: location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:80; }

I have tried: adding config.force_ssl = true to the /cartodb/config/environments/development.rb. but client just gets stuck in an infinite loop of being redirect to https the to http and back again.

aarontract commented 5 years ago

Ok, I think I have worked it out to a proof of concept level.

I don’t know ruby but looking at the \cartodb code there were lots of checks for the ruby environment being production or staging otherwise the protocol was changed to http and or a redirect happened.
So I think the trick was to set the environment to production for cartodb ruby code. Windshaft-cartodb and CartoDB-SQL-API are still running as development

In the Docker File I added: ENV RAILS_ENV production (found from here https://github.com/sverhoeven/docker-cartodb/issues/52)

I had to then duplicated development.rb to production.rb
in /cartodb/config/environments/

and just for testing in /cartodb/config/database.yml database: carto_db_development for production.

I will try to write it up a little better after I have finished testing.