Ruby on Rails Wednesday, July 26, 2017

I think Passenger is running

The following is what I see before I invoked Firefox
ralph-data@ralph-data:~$ date
Wed Jul 26 08:27:49 MDT 2017
ralph
-data@ralph-data:~$ passenger -v
Phusion Passenger 5.1.1
ralph
-data@ralph-data:~$ sudo passenger-status
[sudo] password for ralph-data:
Version : 5.1.1
Date    : 2017-07-26 08:28:50 -0600
Instance: 6eCdJWUs (Apache/2.4.18 (Ubuntu) Phusion_Passenger/5.1.1)

----------- General information -----------
Max pool size : 6
App groups    : 0
Processes     : 0
Requests in top-level queue : 0

----------- Application groups -----------


And once I start Firefox I see
ralph-data@ralph-data:~$ sudo passenger-status
Version : 5.1.1
Date    : 2017-07-26 08:31:25 -0600
Instance: 6eCdJWUs (Apache/2.4.18 (Ubuntu) Phusion_Passenger/5.1.1)

----------- General information -----------
Max pool size : 6
App groups    : 1
Processes     : 4
Requests in top-level queue : 0

----------- Application groups -----------
/home/ralph-data (development):
 
App root: /home/ralph-data
 
Requests in queue: 0
 
* PID: 2602    Sessions: 0       Processed: 22      Uptime: 11s
    CPU
: 7%      Memory  : 79M     Last used: 8s ago
 
* PID: 2614    Sessions: 0       Processed: 1       Uptime: 8s
    CPU
: 4%      Memory  : 60M     Last used: 8s ago
 
* PID: 2623    Sessions: 0       Processed: 1       Uptime: 8s
    CPU
: 4%      Memory  : 52M     Last used: 8s ago
 
* PID: 2632    Sessions: 0       Processed: 0       Uptime: 8s
    CPU
: 0%      Memory  : 2M      Last used: 8s ago

ralph
-data@ralph-data:~$

And this is what I have in /etc/apache2/sites-enabled/ralph-data.com.conf
# Shnelvar
# See https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html
# Turning on
#   LoadModule ssl_module modules/mod_ssl.so
#  appears to break Apache
# This was fixed by running a2enmod ssl.
# The running of a2enmod ssl appears to make the line below unnecessary
# LoadModule ssl_module modules/mod_ssl.so

# Listen 443
<VirtualHost *:443>
 
# See https://www.maketecheasier.com/apache-server-ssl-support/
 
# DocumentRoot /var/www/html
 
DocumentRoot /home/ralph-data/public

 
# Shnelvar:
 
#   See https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/
 
PassengerRuby /home/ralph-data/.rbenv/versions/2.4.1/bin/ruby

 
ServerName ralph-data.com:443
 
ServerAlias www.ralph-data.com:443
 
SSLEngine on

 
# Shnelvar: SSL Certiticate
 
SSLCertificateFile /etc/ssl/private/ralph-data_com.crt

 
# Shnelvar: Pivate key
 
SSLCertificateKeyFile /etc/ssl/private/myserver.key

 
# Shnelvar:
 
#   See https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/
 
# Relax Apache security settings
 
<Directory /home/ralph-data/public>
   
RailsEnv development
   
Allow from all
   
Options -MultiViews
   
# Uncomment this if you're on Apache > 2.4:
   
Require all granted
 
</Directory>
  ServerAlias ralph-data.com
ServerAlias www.ralph-data.com
</
VirtualHost>

This is what I get when I want to see the Apache httpd version
ralph-data@ralph-data:~$ sudo apachectl -V
[sudo] password for ralph-data:
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2017-06-26T11:58:04
Server's Module Magic Number: 20120211:52
Server loaded:  APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"
ralph-data@ralph-data:~$


Thanks for asking.  It's a good review of what I've done. :-)

I've read overviews about Passenger ... but I still don't get what it does.  Does it sit between Apache (httpd)  and Rails?  What does it do that Apache (httpd) doesn't do?

Ralph




On Wednesday, July 26, 2017 at 7:16:39 AM UTC-6, Hassan Schroeder wrote:
On Wed, Jul 26, 2017 at 2:53 AM, Ralph Shnelvar <ral...@dos32.com> wrote:

>> First, "Apache" is the name of an organization; "Apache httpd" is a
>> web server (which many people erroneously refer to as "Apache").
>>
> Lordy, you're even more of a pedant than I am.  :-)

It's a losing battle, but the ASF (Apache Software Foundation)
hosts/sponsors hundreds of OSS projects (e.g. Apache Tomcat,
Apache Commons) and it can get confusing when people use
"Apache" without any qualifier. But moving on...

>  I installed the system myself.

Do you remember configuring httpd for something called
"Passenger"? If not, what kind of configuration was done to
access your Rails app?

> So I use the environment variable RALPH_SUPPRESS_HTTPS as a proxy for
> whether I'm using webrick or Apache httpd

You can get the command used to start the server (last shell
command) from the environment with "printenv _" e.g.

  puts "started with #{`printenv _`}"

Try putting the above line at the bottom of config/environment.rb
and starting your app both ways to confirm.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cf862433-0c25-4755-addc-c9ba9736340a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

https://stackoverflow.com/questions/45329731/csrf-tokens-to-not-match-what-is-in-session-rails-4-1


We are seeing an unfortunate and likely browser-based CSRF token authenticity problem in our Rails 4.1 app. We are posting it here to ask the community if others are seeing it too. 

Please be aware that most error reporting tools — like Honeybadger — automatically suppress ActionController::InvalidAuthenticityToken, so you don't normally see the problem in your error reporting tool unless you go out of your way to see it.

Here's the problem, and this is NOT a development issue — it is a production issue that has yet to be diagnosed. 

The exception we see is simply ActionController::InvalidAuthenticityToken on normal logins to our website. Upon careful examination of the authenticity_token sent by the form and the session's _csrf_token (we are using active_record_store as our session_store setting), they just don't match. Upon direct examination, I can conclude only that they are completely different tokens, but I don't know why. 

This is not a simple newbie developer question, please DO NOT answer with basic answers about how the CSRF token needs to be passed from the client to the server, or how to skip forgery protection on my controllers. I am not interested hearing from anyone with either of those two answers: You don't know what you're talking about and you don't understand the depth and complexity of the issue. I am only interested in hearing from people with high-traffic websites who have can confirm this is happening on a non-insignificant number of visitors (and strangely seems to affect certain browsers more often than other browsers.)

We see this problem broadly, maybe about 1-2% of our high traffic website. I see it only in Production, I am unable to reproduce it in development whatsoever. 

I see it on IE 11 and Edge browsers most (you will note Rails 4.1 was released before IE 11 and Edge), but also on Chrome on Android and occasionally mobile Safari too.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/249c094c-8049-4061-8ba3-b8c38ef1ae1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

If you preload your test database with all fixture data via the rake task:

bin/rails db:fixtures:load

And set self.pre_loaded_fixtures to true:

class ActiveSupport::TestCase
  self.pre_loaded_fixtures = true
  self.use_transactional_tests = true # the default

  fixtures :all
end

Would you expect the fixtures to be deleted and reinserted on every test run (caused by ActiveRecord::FixtureSet.create_fixtures – the same code exercised by the rake task)? Given the documentation on Transactional Tests, I'd imagine this to be unexpected behaviour but, regardless of options configured, fixture data is always reinstalled by the fixtures :all call.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7fa39237-b9ce-42b1-919b-5c4a203b58a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.