Discussion:
[SOGo] Connect SOGo to memcached and pgsql with unix socket
Romain LE DISEZ
2011-06-15 14:43:58 UTC
Permalink
Hello all,

just a little tip, it could be useful to someone.



Problem with memcached is that there is no access control. You can force
memcached to bind to 127.0.0.1, but it's a poor option because every
process can access it.

With UNIX socket, you can strictly restrict access to memcached.

Run memcached (use the configuration file of your distrib):
memcached -d -u sogo -s /tmp/memcached.sock -a 0700


And update the configuration of SOGo:
defaults -u sogo write sogod SOGoMemcachedHost /tmp/memcached.sock



You can also use UNIX socket for PostgreSQL. On EL6, by default, the
UNIX socket of PostgreSQL is in /tmp:
/tmp/.s.PGSQL.5432

So, set your configuration as following:
defaults -u sogo write sogod OCSFolderInfoURL postgresql://%2Ftmp/sogo/sogo_folder_info
defaults -u sogo write sogod OCSSessionsFolderURL postgresql://%2Ftmp/sogo/sogo_sessions_folder
defaults -u sogo write sogod SOGoProfileURL postgresql://%2Ftmp/sogo/sogo_user_profile

/!\ WARNING /!\
You can't update the PostgreSQL URL without updating the content of the
table sogo_folder_info.

Please note that:
- thanks to ident, you don't need to specify user and password if the
database owner is "sogo".
- You must only specify the folder containing the socket file,
replacing / with %2F

Greetings.
--
Romain LE DISEZ <romain.ledisez-2yA+***@public.gmane.org>
Daniel Berteaud
2011-09-01 09:39:45 UTC
Permalink
Post by Romain LE DISEZ
Hello all,
Hi
Post by Romain LE DISEZ
just a little tip, it could be useful to someone.
Problem with memcached is that there is no access control. You can force
memcached to bind to 127.0.0.1, but it's a poor option because every
process can access it.
With UNIX socket, you can strictly restrict access to memcached.
memcached -d -u sogo -s /tmp/memcached.sock -a 0700
defaults -u sogo write sogod SOGoMemcachedHost /tmp/memcached.sock
I tried this method, but unfortunatly, it doesn't work, SOGo cannot
connect to memcached:

Sep 01 11:14:40 sogod [32276]: <0x0x9427068[SOGoCache]> Using host(s)
'/var/run/memcached/memcached.sock' as server(s)
[...]
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'dani+attributes': "HOSTNAME LOOKUP
FAILURE"
Sep 01 11:14:45 sogod [32276]: SOGoRootPage successful login for user
'dani' - expire = -1 grace = -1
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'session:uJj9J5D3Mj7PRCEEg1HXmw==':
"HOSTNAME LOOKUP FAILURE"
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'dani+attributes': "HOSTNAME LOOKUP
FAILURE"
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'dani-rwNdu3Xx/YEdnm+***@public.gmane.org+attributes':
"HOSTNAME LOOKUP FAILURE"
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'contact-rwNdu3Xx/YEdnm+***@public.gmane.org+attributes':
"HOSTNAME LOOKUP FAILURE"
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'webmaster-rwNdu3Xx/YEdnm+***@public.gmane.org+attributes':
"HOSTNAME LOOKUP FAILURE"
Sep 01 11:14:45 sogod [32276]: <0x0x9427068[SOGoCache]> an error
occurred when caching value for key 'dani-rwNdu3Xx/YEdnm+***@public.gmane.org+attributes':
"HOSTNAME LOOKUP FAILURE"


Looks like SOGo is trying to resolve /var/run/memcached/memcached.sock
(which is the path of the socket I use for memcached) as a hostname
instead of using it as a unix socket.

am I missing something ?

Regards, Daniel
Post by Romain LE DISEZ
You can also use UNIX socket for PostgreSQL. On EL6, by default, the
/tmp/.s.PGSQL.5432
defaults -u sogo write sogod OCSFolderInfoURL postgresql://%2Ftmp/sogo/sogo_folder_info
defaults -u sogo write sogod OCSSessionsFolderURL postgresql://%2Ftmp/sogo/sogo_sessions_folder
defaults -u sogo write sogod SOGoProfileURL postgresql://%2Ftmp/sogo/sogo_user_profile
/!\ WARNING /!\
You can't update the PostgreSQL URL without updating the content of the
table sogo_folder_info.
- thanks to ident, you don't need to specify user and password if the
database owner is "sogo".
- You must only specify the folder containing the socket file,
replacing / with %2F
Greetings.
--
Daniel Berteaud
FIREWALL-SERVICES SARL.
Société de Services en Logiciels Libres
Technopôle Montesquieu
33650 MARTILLAC
Tel : 05 56 64 15 32
Fax : 05 56 64 15 32
Mail: daniel-v+aXH1h/***@public.gmane.org
Web : http://www.firewall-services.com
--
users-***@public.gmane.org
https://inverse.ca/sogo/lists
Loading...