Monday, August 15, 2016

#700 - Apache 2.4 HTTPS on Windows Server stops working after running for several hours

I was trying setup an Apache 2.4 server on Windows Server 2008 R2 to server static files for my web applications over SSL. It ran smoothly for couple hours and than hang forever. I tried to restart server every time it happens but it only last for several hours and then crashed again. It frustrated me and after looking to the configuration of Apache for a while, I finally make it works beautifully.

1. Enable MPM in httpd.conf with those settings:

By default, this MPM uses advanced Windows APIs for accepting new client connections. In some configurations, third-party products may interfere with this implementation, with the following messages written to the web server log:

Child: Encountered too many AcceptEx faults accepting client connections.
winnt_mpm: falling back to 'AcceptFilter none'.
The MPM falls back to a safer implementation, but some client requests were not processed correctly. In order to avoid this error, use AcceptFilter with accept filter none.

AcceptFilter http none
AcceptFilter https none

# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf

For more information about MPM, please read this.

2. Increase the number of threads per child process in /extra/httpd-mpm.conf

<IfModule mpm_winnt_module>
    ThreadsPerChild      1000
    MaxRequestsPerChild    0

3. Some minor changes in SSL configuration (/extra/httpd-ssl.conf)

Listen 443 https
ErrorLog "${SRVROOT}/logs/error_.log"
TransferLog "${SRVROOT}/logs/access_.log"

4. Restart Apache (in cmd) and see the magic

net stop Apache
net start Apache