Slow response testing localhost sites in Google Chrome on Mac OS X

Last week I noticed the response of localhost requests were slow in Google Chrome, but responded very quickly in Safari. I suspected Chrome was submitting my local requests to it’s data hunger servers to build an even better profile of me.
I tweaked a lot of Chrome settings so everything would be kept private, but no success. After several attempts I found the problem:

To test multiple sites and testing multi-domain rails applications I’ve changed my /etc/hosts file to contain the following items.

127.0.0.1 nice-domain.local
127.0.0.1 nice.sub-domain.local
127.0.0.1 gamecreatures.local

So calling: “gamecreatures.local” in Chrome causes a too long delay for showing something..
calling “gamecreatures.local” in Safari responded instantly..

After doing some research, I’ve learned Apple is doing something special with the .local postfix. It is used by the Bonjour services somehow. I don’t know exactly what, but they do…

So changing all the extension from “.local” to something else for example “.loc” solved the issue for me:

127.0.0.1 nice-domain.loc
127.0.0.1 nice.sub-domain.loc
127.0.0.1 gamecreatures.loc

Now Chrome also responds instantly…
Sorry Google for “assuming” you trying to steal all data from me… (Or should I use the _nomap extension for this one too ?!?)

Ruby on Rails / ChiliProject encoding issues

This week I’ve decided to exchange Redmine for the ChiliProject. The reason for this is the support for Ruby 1.9. My Apache Passenger server runs Ruby 1.9 so for Redmine I needed a seperate webserver.

When I tried to access the “My Account” page I recieved the following error:

ArgumentError (invalid byte sequence in US-ASCII):
  <internal:prelude>:10:in `synchronize'
  passenger (3.0.7) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
  passenger (3.0.7) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.7) ...
`handle_spawn_application'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.7) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.7) helper-scripts/passenger-spawn-server:99:in `<main>'

Rendering /data/www/rails/chili/public/500.html (500 Internal Server Error)

Solution

How should I solve this? The chiliproject has an issue related to this: https://www.chiliproject.org/issues/591.

The following Apache configuration fixed the issue: (The sample is on a FreeBSD system)

I added the following code to a file in the /usr/local/apache22/envvars.d/environment.env

export LC_CTYPE="en_US.UTF-8"

Problems I ruled out or fixed

While trying I also made sure the following things were configured:

I made sure the database is UTF-8. I re-created the database
an ran the migrations again.

create database chiliproject character set utf8;

I used the mysql2 connector instead of the mysql connector in database.yml

PHP’s Frustrating Flush

PHP not listening when you try to flush data. Try the following, it helped for me:


@ob_flush(); // try a normal flush
flush();

If PHP isn’t flushing it could be your webserver that’s collecting your output for gzipping:


mod_gzip_on no

This worked for me..

Limiting Subversion Users via SVN Access File

I was in a situation I wanted to setup a SVN repostitry which allowed a friend of my to only contact certain projects readonly. To other projects he should have commit rights. Some projects are publicly accessible.

Well after some sweating I found out I was trying it the wrong way. I was trying very hard to use the LIMIT option of the apache config file.. Well this is NOT the way to go. It seems possible to define a SVN ACL file which is extremely flexible in defining the rights. You can even limit rights on path basis !

Summary:

Here ‘s my solution.
The apache config file

&lt;Location /subversion&gt;

<location>DAV svn
SVNParentPath /data/svn/repos</location>

AuthType Basic
AuthName "Authorization for required"
AuthUserFile /data/svn/.htpasswd
AuthzSVNAccessFile /data/svn/svn-acl

require valid-user
&lt;/Location&gt;

The ACL file “/data/svn/svn-acl”

## The groups
[groups]
committers=john, jake

readers=jan, emma

#
# Format:
#
[project:/]
@committers = rw
emma = r
* = r

[projectX:/path/]
committers = rw
emma = rw
* = r

BTW. You can create users with the standard Apache command

# Create the passwordfile
htpasswd -c /data/svn/.htpasswd  johndoe

# Add a second user
htpasswd /data/svn/.htpasswd  emma