How to force https on IIS webiste?

Edit web.config file in your website directory and carefully add this lines (remember to change domain name):


File: web.config
----------------

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Force HTTPS" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://website.com/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Brutal fix for “Incorrect string value:” error in Matomo (Piwik)

If you’re using Matomo (previously Piwik) on MS IIS and MariaDB  and you’re getting a lot of these:

[06-Jun-2018 11:56:36 UTC] Error in Matomo (tracker): Error query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xC3_\xC6\x92\xC3\x82...' for column 'name' at row 1 In query: INSERT INTO matomo_log_action (name, hash, type, url_prefix) VALUES (?,CRC32(?),?,?) Parameters: array (   0 => 'website.com/Ă_ƒÂ¢',   1 => 'website.com/Ă_ƒÂ¢',   2 => 1,   3 => 1, )

You can use my fix (because literally nothing that can be found in the internet is helpful in this case).

Continue reading Brutal fix for “Incorrect string value:” error in Matomo (Piwik)

PHP reading problem with files larger than 2 GB

If you’ll ever have problem with opening (fopen) and reading (fread) files larger than 2 GB in your PHP script. Check your version of scripting engine. In my case switching to 64 bit solved the problem. Please mind that this error is very hard to debug because PHP does not log anything (same as MS IIS) in such case. It simply resets client connection…

How to remove unwanted HTTP Response Headers in IIS 7.5

Hiding server software is one of ways to protect your services from hackers. It’s quite easy to obscure IIS identity. In few steps I’ll show you how to accomplish this task on WIMP stack.

Continue reading How to remove unwanted HTTP Response Headers in IIS 7.5

How to manualy recreate AWstats logs on Windows

Sometimes it happens that your scheduled task on Windows missed some logs. I’ve recently had a such problem because I’ve deleted a Windows user that created AWstats task. What did I do to repair this awkward situation?

Firstly you cannot simply regenerate daily log from the past. In this case AWstats will simply skip old records. Follow this steps:

  1. Go to AWstats data directory (AWstats\cgi-bin\data).
  2. Use Windows search ability to show only problematic files (if file name is awstats102013.yoursite.txt simply type yoursite in a searchbox).
  3. Mark all found files and move them to the temporary location.
  4. Now run Windows cmd.
  5. Go to AWstats tools dir. In my case:
    cd C:\awstats-7.0\tools
  6. Now create a merged log for a problematic website:
    :: where xx is unique IIS webiste id 
    logresolvemerge.pl L:\LOG_DIR\W3SVCxx\* > L:\LOG_DIR\W3SVCxx\merged.log
  7. Go to awstats.pl location:
    w:
    cd w:\wwwroot\AWstats\cgi-bin\
  8. Parse merged file:
    awstats.pl -config=yoursite -LogFile=L:\LOG_DIR\W3SVCxx\merged.log -update
  9. Place files from steps 2-3 back to their location. Don’t overwrite new files! Simply skip old ones.
  10. You should be able to see complete stats for your website.

TIP: How to dermine your webiste unique id? Simply go to IIS manager and click advanced settings in a right pane after selecting website.