Apache: send data from reverse Proxy to Application Server

Monday, October 18, 2010 Posted by

It’s possible to send data from the reverse proxy to the server doing the work using HTTP Headers. This includes information if HTTPS is used (only the front server knows that) or geoIP information.

Example Apache conf

<Location /eParcel>
# tells if we are running http or https s
RequestHeader set X-Forwarded-HTTPS “%{HTTPS}s”
<Location>

ProxyPass /tintifax http://example.com/tintifax/
ProxyPassReverse /tintifax http://example.com/tintifax/

Curl and NTLM

Wednesday, October 13, 2010 Posted by

Yes, we can use CURL to talk to a Sharepoint server and retrieve a document:

curl –ntlm -u username:password http://server/my/personal/tintifax/Shared%20Documents/10MBrandom.doc > example.log/

HTTP Uploads larger than 2 GB

Tuesday, September 28, 2010 Posted by

Do not work – I ran into a problem trying to make the upload size for one of my application bigger. Firefox, Internet Exporer and Safari all failed. The reason: they mess up the headers – Content-Length does an overflow

POST /uploadtest.php HTTP/1.1
User-Agent Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; )
Content-Type multipart/form-data; boundary=---------------------------7da301630063a
Accept-Encoding gzip, deflate
Content-Length -156552375
Pragma no-cache

A simple PDO example

Monday, September 27, 2010 Posted by


// create PDO Database connection
try {
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
} catch(PDOException $e) {
echo $e->getMessage();
throw($e);
}
// prepare the statemant
$sql = $dbh->prepare("
SELECT
city, count(city), sum(counter) cnt
from geoip
where
country_name = :countryname
group by city;
");
// replace the bind parameters with variables
$sql->bindParam(':countryname', $countryname, PDO::PARAM_STR);
// execute the statemant
$sql->execute();
// check for errors - PDO catches them silently
if ($sql->errorCode() != '0000' ) {
$msg = $sql->errorInfo();
throw new Exception($msg[2]);
}
// iterate over the results
foreach ($sql as $row) {
echo "access via index: " . $row[0] . "\n";
echo "access via associative array: " . $row["cnt"] . "\n";
}

Oracle 10 Client on Windows 7

Tuesday, August 17, 2010 Posted by

If you need the full Oracle Client on your Win7 machine, you are in a bit of trouble.

Windows 7 is internal windows 6.1 and the setup routine checks for windows 5, 5.someting and 6.0. So no Windows 7.

But there is a hack: turn off the system check with the flag -ignoreSysPrereqs

so running

setup.exe -ignoreSysPrereqs

form a cmd does the trick. You’ll have to overwrite the error later in the setup routine by clicking the failed checkbox.

mysql: removing a timestamps on update CURRENT_TIMESTAMP

Monday, August 2, 2010 Posted by

Situation: you have a table and a timestamp in it. Thee is a on update CURRENT_TIMESTAMP on the column. But you want to get rid of it:

ALTER TABLE yourTable
CHANGE  someCol somecol TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

cwrsync 4.0.4 to UNC Paths

Thursday, July 15, 2010 Posted by

It seams to me that handling of UNC paths changed since the last version i used. After some pain i am now able to sync from europe to china again. Here are some hints for other poor souls that may prove helpfull:

* If you are using rsync on windows to sync to an UNC Path (\\server\some\path) on the receiving end – be sure to run the service as an account that can access the share. In my case a domain user was needed, the local service account  (svccwrsync) failed of course

* UNC Paths worked previously like this (in rsyncd.donf):
path    = \\fshsmsxxx\d$\Public Share\Engineering\somePath

Not any longer. Now with rsync 3.07 its
path    = //fshsmsxx/d$/Public Share/
Engineering/somePath

rsync on windows chown failed: Invalid argument (22)

Monday, July 12, 2010 Posted by

Using cwrsync 4.04 a lot of  “chown failed: Invalid argument (22)” showed up.

After some research the following tricks removed those annoying erros:

In rsyncd.conf set user and group to :
uid = 0
gid = 0

in the rsync call, replace -a (which is short for -rlptgoD (recursive, copy symlinks, preserve permissions, preserve modification times,  preserve group,  preserve owner , preserve device files,preserve special files  ) )
with -rt (recursive, preserve times)

Now using
rsync –super –recursive –delete –compress –times testSource CWsync@targetServer::testDestination

see http://www.itefix.no/i2/node/12340 for details

Remotly killing a RDP Session

Wednesday, June 2, 2010 Posted by

Server full, or a session handing .. you know it’s a pain. But how to remotly get you a free session?

First check the sessions

qwinsta /server:<servername>

SITZUNGSNAME   BENUTZERNAME      KENNUNG STATUS  TYP         GERÄT
console                        0                                     Verbunden                                    wdcon
rdp-tcp                     65536                              Bereit                                               rdpwd
rdp-tcp#5               xxchr95                         2                                      Aktiv       rdpwd
rdp-tcp#13            xxkla19                           1                                     Aktiv        rdpwd

Then, kick a sesson

rwinsta 2 /server:<servername>

Where 2 is the Session Id from the qwinsta command

Or, if you happen to be admin on the target machine take over the console RDP session

mstsc /console /v:<server>

Find out what mysql queries are slow

Wednesday, June 2, 2010 Posted by

So you are using mysql and have some data in your DB … say 2 million rows or something.  Not it’s about time to see how your SQL queries are doing, do some profiling, but … but how to you find out what sql queries are slow? Where you are missing that index? Try the following in your mysql.ini

[mysqld]
#enable slow query logs
log-slow-queries = d:/your/path/to/log/slow.log
# default of “slow” is 10 seconds, set it to 1
long_query_time = 1
# log *EACH AND ANY* query not using an index (this may be a lot till you fix it)
log-queries-not-using-indexes


Then you see where you’re not using the index, where you forgot it. Maybe use EXPLAIN on some of your longer queries to find out how to improve them

[mysqld] 
#enable slow query logs
log-slow-queries = d:/phpapps/xampp/mysql/log/slow.log
# default of "slow" is 10 seconds, set it to 1
long_query_time = 1
# log *EACH AND ANY* query not using an index (this may be a lot till you fix it)
log-queries-not-using-indexes