Forem Creators and Builders

Manuel
Manuel

Posted on • Updated on

Forem - Blank Page after login using Docker

Hi! Forem is very good! I was able to install it using the guide for linux without any issue. However when trying the docker approach i am getting a blank page after try to login.

The error that is showing in the logs is this:

rails_1      | Incoming Headers:
rails_1      |   Origin: http://64.227.102.95:3000
rails_1      |   Path-Info: /users/sign_in
rails_1      |   Access-Control-Request-Method:
rails_1      |   Access-Control-Request-Headers:
rails_1      | Started POST "/users/sign_in" for 177.215.138.38 at 2021-05-08 08:33:54 +0000
rails_1      | Processing by Devise::SessionsController#create as HTML
rails_1      |   Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"admin@forem.local", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Continue"}
rails_1      |   SiteConfig Load (0.9ms)  SELECT var, value FROM "site_configs"
rails_1      |   ↳ config/initializers/rails_settings.rb:36:in `block (3 levels) in inherited'
rails_1      | HTTP Origin header (http://64.227.102.95:3000) didn't match request.base_url (http://64.227.102.95:3000)
rails_1      | Completed 200 OK in 35ms (ActiveRecord: 3.9ms | Allocations: 6019)

Enter fullscreen mode Exit fullscreen mode

Seems that something is missing HTTP Origin header (http://64.227.102.95:3000) didn't match request.base_url (http://64.227.102.95:3000)

I also put an nginx reverse proxy and added a domain however i am getting the same error.

Want to know if someone knows how to solve this issue that can help me?

Discussion (11)

Collapse
manuel profile image
Manuel Author

The issue was that when you try to install using docker-compose the .env file is not loaded by default, you can include the variables directly on the docker-compose or try to load the env file.

If someone else is having issues with docker installation please let me know and will try to help, I spent couple of days with the production installation but finally is working very good.

Collapse
ce7in profile image
Muhammed Cetin • Edited

What file should I include the APP_DOMAIN variable? Is it container-compose.yml? I've edited the APP_DOMAIN variable with "localhost" which is the url of the project instead of "rails" but the error persists when I'm trying to sign in with default admin account. Can you help me?

forem.dev/remoteimages/uploads/art...

Collapse
manuel profile image
Manuel Author

Hi @ce7in Yeah for the first attempt that worked i added all the environment variables of the .env file on the docker-compose.yml they should be on the environment section mainly on the rails service.

You can also use --env-file option of docker-compose to include the .env file that should be cleaner and simple to use.

Thread Thread
ce7in profile image
Muhammed Cetin

Thank you @manuel . I've one more question. I've visited your forem instance and it was fully published. What platform did you use to turn forem into production mode? Is it Heroku or DigitalOcean? When I'm trying to deploy forem on Heroku it throw an error like on the images I've added below. Do you have an idea about that?

forem.dev/remoteimages/uploads/art...
forem.dev/remoteimages/uploads/art...

Thread Thread
manuel profile image
Manuel Author

Np! It's hosted on DigitalOcean. No I didn't get that error. The error for the images that i got where that i didnt have a Cloudinary Account, just created one change environment variables and solved the issue.

The other issue i had was regarding Fastly, i didnt have an account so but created an environment variable with: FASTLY_CDN_URL: hackerss.com and that solve the issue

Collapse
akhil profile image
Akhil Naidu

I guess your issue was resolved? I was able to access your Forem.

Collapse
manuel profile image
Manuel Author

Hi Akhil!

The issue is still there, when trying to login there is a blank page after put the credentials: 64.227.102.95:3000/users/sign_in

I tried different things but not able to login when installed forem using docker

Collapse
djuber profile image
Daniel Uber • Edited

Hi Manuel, I think we're seeing this generally in docker installations - I think I have a fix proposed for this (the issue appears to be the APP_DOMAIN used in the docker compose file causes this validation error when we check the certificate).

This is the key part of the error message that's showing the problem with the login post validation

HTTP Origin header (http://64.227.102.95:3000) didn't match request.base_url (http://64.227.102.95:3000)
Enter fullscreen mode Exit fullscreen mode

I'm also seeing this reported as github.com/forem/forem/issues/13696 so it's definitely not limited to your installation.

Thread Thread
gkbaby profile image
gkbaby

Hi Daniel, Thank you, I copied changes from your PR and it worked.
Few cases to consider:
I ran it on a azure server and its ip-address:3000 showed the same error with the change. I had to connect it to a subdomain with nginx proxy with APP_DOMAIN as subdomain to make it past through the sign in. So environment variable will be a better choice i think

Thread Thread
djuber profile image
Daniel Uber

Yes, I think the environment variable is a better solution - the docker-compose file was originally written to support local development using docker (I think we didn't have enough people using it locally to notice the issue you saw with the login submissions failing).

I've merged the changes into the main branch (so you shouldn't need to worry about re-applying that patch going forward). However, do feel free to add any environment variables you need to the compose file or pass them at startup.

Collapse
ussaaron profile image
Aaron Martinez

Hi guys,

The white screen of death is caused by url reroute mid-build. Basically, all the hosting settings need to be set in the .env file (before) you start building Forem. If you change the domain url between the start of the build and seed admin confirmation, it will break the build. This is actually common for many apps, but because of the way Forem builds progress, its not always clear what these settiings are. As a rule of thumb, all hosting environmet variables including AWS, etc--should be set prior to a build. This should solve the problem.

Additionaly, this may happen if your seed admin has not been confirmed with sendgrid. Do not try the sendgrid workaround if you want full super admin access. Set up your sendgrid account (prior) to the Forem build.