Friday, March 21, 2014

Lighttpd: full site with SSL with exception of a url / path / directory

Well.. perhaps you need SSL in your site but you want to exclude a concrete path / url. This is my config:


# When http then https but no redirect for "knowledgebase" path
$HTTP["scheme"] == "http" {
$HTTP["host"] =~ "secure.site.com" {
url.redirect = ( "^/(?!(knowledgebase).*)" => "https://secure.site.com/$1" )
server.document-root = "/site/secure"
}
}
#behavior for SSL
$HTTP["scheme"] == "https" {
$HTTP["host"] =~ "^secure\.site\.com" {
ssl.engine = "enable"
server.document-root = "/site/secure"
server.max-keep-alive-idle = 3
}
#if "knowledgebase" is accessed from inside of the SSL site then exit to http!
$HTTP["url"] =~ "knowledgebase" {
setenv.add-environment = ( "HTTPS" => "off" )
ssl.engine = "disable"
url.redirect = ( "^/(.*)" => "http://secure.site.com/$1" )
}
}
view raw gistfile1.txt hosted with ❤ by GitHub

Wednesday, March 19, 2014

curl + IPv6: common errors using direct IP

FAIL!
$ curl -6 "http://a00:1450:4007:805::1018/" 
curl: (3) IPv6 numerical address used in URL without brackets 
FAIL!
$ curl -6 "http://[a00:1450:4007:805::1018]/"
curl: (3) [globbing] bad range in column 13
BINGO!
$ curl -g -6 "http://[2a00:1450:4007:805::1018]/"

302 Moved 
The document has moved

Wednesday, March 12, 2014

Myloader: resolving errors with no clear message

If you have a special configuration in mysqld (no default config) perhaps you will find these two cases of error working with myloader tool:

1) The first issue looks like a problem with the backup file...... but it is not. Message:
** (myloader:42526): CRITICAL **: cannot open file vcadminweb.message.sql.gz (24) * (myloader:46190): CRITICAL
In my case, I needed to check and to change the open files:
ulimit -n 10000        ..... and solved!
2) The second one looks like a problem accessing to the database.... but it is not. Message:
**: Error switching to database CMSB076 whilst restoring table multidevicevideo_players
In my case, it was a timewait very low in the mysqld config.
wait_timeout       = 300 
solved the issue for me.

Monday, March 10, 2014

Mysql: Drop database with dash in name

The issue:
mysql> drop database my-web;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-web' at line 1
mysql> drop database "my-web";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"my-web"' at line 1
mysql> drop database 'my-web';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''my-web'' at line 1
 
The trick:
mysql> drop database `my-web`;
Query OK, 83 rows affected, 1 warning (0,02 sec)

Wednesday, March 5, 2014

Glassfish 4 tricks on CentOS 6

Three tricks here.

One. Init.d script for CentOS 6:


#!/bin/bash
# description: Glassfish Start Stop Restart
# processname: glassfish
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/default
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/usr/local/glassfish4/glassfish
GLASSFISH_USER=glassfish
case $1 in
start)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
stop)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
;;
restart)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
esac
exit 0
view raw glassfish hosted with ❤ by GitHub


Two. Changing umask permission in Glassfish 4:

Add "umask 002" just before the "exec" line in $GLASSFISH_HOME/bin/asadmin

Three. Changing general logging file in Glassfish 4:

Change logging.properties file line to (by example):
 com.sun.enterprise.server.logging.GFFileHandler.file=/var/log/glassfish/server.log