Monthly Archive for January, 2010

How to remove ^M from files

When you transfered a file from Windows to Linux, you have ^ M characters that appear. This is due to the end line characters on Windows (\ r \ n) which are differents from Linux (\ n). There is some tips to remove them.

  • On vi, in command mode
:%s/[ctrl+v][ctrl+M]//
  • On emacs
M-%
  • From the shell, install tofrodos (on Debian):
$ dos2unix file.txt

$ unix2dos file.txt

The second command do the opposite.

Squid, HTTP authentification in accelerator mode

When you use HTTP authentification, like in .htaccess with Apache, by default Squid doesn’t support this feature. You need to add an option, login=PASS,  to the cache_peer to forward HTTP authentification requests to the backend servers:


cache_peer 172.16.1.1 parent 80 0 login=PASS no-query originserver weight=1

How to use differents cache_peer in Squid

In accelerator mode, you can use the same Squid instance with differents cache_peer configuration using acl to choose where requests will go:

acl example2 dstdomain www.example2.com

cache_peer 172.16.1.1 parent 80 0 no-query originserver weight=1 name=clust1

cache_peer 172.16.1.2 parent 80 0 no-query originserver weight=1 name=clust2

cache_peer_access clust1 allow !example2

cache_peer_access clust2 allow example2<code>

Request for the domain www.example2.com go to clust2 (172.16.1.2). However, request for others domain, like www.toto.com go to clust1 (172.16.1.1).