Forum

Script gets called twice

velvetpaw
27 February 2014, 18:12
Hey there!

Hiawatha version: Hiawatha v8.4, cache, Command Channel, IPv6, Monitor, reverse proxy, SSL, URL toolkit, XSLT
Operating System: Linux 3.12-1-amd64 #1 SMP Debian 3.12.9-1 (2014-02-01) x86_64 GNU/Linux

I've recently switched my VHost from regular HTTP to HTTPS. Now, since I did that my script gets called twice. Following Scenario:

Script to run (in Bash.) : index.sh

#!/bin/bash
date +%s >> $logfile
echo "Content-type: text/html"
echo ""
echo ""

Configuration of Hiawatha:

CGIhandler = /bin/bash:sh
UrlToolkit {
ToolkitID = myname
RequestURI isfile Return
Match .* Expire 12 months
Match .*\.sh$ Expire 1 hours
Match .*\.css$ Expire 12 months
Match .* Rewrite /index.sh
}

VirtualHost {
Hostname = myhostname.com
WebsiteRoot = /var/www/info
StartFile = index.sh
AccessLogfile = /var/log/hiawatha/info_access.log
ErrorLogfile = /var/log/hiawatha/info_error.log
ExecuteCGI = yes
UseToolkit = myname
UseGZfile = yes
PasswordFile = basic:/etc/hiawatha/users_info
RequireSSL = yes
}

What happens if I access "index.sh" on my server:

The access-log states following:

80.123.xxx.xxx|Thu 27 Feb 2014 18:10:13 +0100|200|72526|velvetpaw|GET /index.sh HTTP/1.1|Host: myhostname.com|Connection: keep-alive|Cache-Control: max-age=0|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8|User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36|Accept-Encoding: gzip,deflate,sdch|Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4,ja;q=0.2

The error-log does not state anything.

The $logfile, accessed via the Bash script writes the following:

1393521013
1393521013

I've come across this since I wrote a really simple "Access-Counter", that just increments a number in a file. However, when using SSL it always increments by 2 every time I access index.sh.

As soon as I disable RequireSSL = yes it stops doing that.

Any Idea? Config fault?

Please tell me if you need any more information!

Thank you for your time!
Hugo Leisink
28 February 2014, 00:57
Weird, never heard of that before. Maybe it's the browser requesting /favicon.ico or something? Please, use a proxy like Fiddler2 to see what's going on.
velvetpaw
28 February 2014, 11:27
Hello!

Thanks for your quick response!

You were right! It's requesting the favicon, which then gets rewritten to /index.sh. The solution was to put:

Match ^/(favicon.ico|robots.txt|sitemap.xml)$ Return

on top of my Rewrite rules!

(I feel a bit dumb now.)

Thanks for your assistance. Have a nice weekend.


Hugo Leisink
28 February 2014, 11:28
You're welcome!
This topic has been closed.