Mod_fcgid: error reading data from FastCGI server / 500 Internal Server Error

500-errorapache-2.4mod-fcgidsuexec

I've trying to set up an IIPImage server but the Images won't display:
https://oooledge.de/wisski_views/b719fd1ac3844863103c508912965b883443

First here are logs, configs, modules and permissions:

suexec.log

[2019-08-16 07:34:11]: uid: (10000/rnsrk) gid: (1003/1003) cmd: cgi_wrapper
[2019-08-16 13:22:11]: uid: (10000/rnsrk) gid: (1003/1003) cmd: iipsrv.fcgi
[2019-08-16 13:22:11]: command iipsrv.fcgi not in docroot (10000)

apache2 error.log

[Fri Aug 16 14:02:13.594904 2019] [fcgid:warn] [pid 18488:tid 139942348928768] (104)Connection reset by peer: [client 85.239.100.129:34372] mod_fcgid: error reading data from FastCGI server
[Fri Aug 16 14:02:13.594973 2019] [core:error] [pid 18488:tid 139942348928768] [client 85.239.100.129:34372] End of script output before headers: iipsrv.fcgi

this is my http.conf

<IfModule mod_ssl.c>

    <VirtualHost 91.250.115.48:443 >
        ServerName "oooledge.de:443"
        ServerAlias "www.oooledge.de"
        ServerAlias "ipv4.oooledge.de"
        UseCanonicalName Off

        DocumentRoot "/var/www/vhosts/oooledge.de/httpdocs"
        CustomLog /var/www/vhosts/system/oooledge.de/logs/access_ssl_log plesklog
        ErrorLog "/var/www/vhosts/system/oooledge.de/logs/error_log"

        <IfModule mod_suexec.c>
            SuexecUserGroup "rnsrk" "psacln"
        </IfModule>

        <IfModule mod_userdir.c>

            UserDir "/var/www/vhosts/oooledge.de/web_users/*"
        </IfModule>


        Alias "/plesk-stat" "/var/www/vhosts/system/oooledge.de/statistics"
        <Location  /plesk-stat/>
            Options +Indexes
        </Location>
        <Location  /plesk-stat/logs/>
            Require valid-user
        </Location>
        Alias /webstat /var/www/vhosts/system/oooledge.de/statistics/webstat
        Alias /webstat-ssl /var/www/vhosts/system/oooledge.de/statistics/webstat-ssl
        Alias /ftpstat /var/www/vhosts/system/oooledge.de/statistics/ftpstat
        Alias /anon_ftpstat /var/www/vhosts/system/oooledge.de/statistics/anon_ftpstat
        Alias /awstats-icon /usr/share/awstats/icon

        <IfModule mod_fcgid.c>
            FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/oooledge.de/etc/php.ini
            FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
            FcgidMaxRequestLen 134217728
            FcgidIOTimeout 240
        </IfModule>

        TimeOut 240
        <Directory /var/www/vhosts/oooledge.de/httpdocs>

            <IfModule mod_fcgid.c>
                <Files ~ (\.fcgi$)>
                    SetHandler fcgid-script
                    Options +ExecCGI
                </Files>
            </IfModule>
            <IfModule mod_fcgid.c>
                <Files ~ (\.php$)>
                    SetHandler fcgid-script
                    FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
                    Options +ExecCGI
                </Files>
            </IfModule>

            SSLRequireSSL

            Options -Includes -ExecCGI

        </Directory>

        <Directory "/var/www/vhosts/system/oooledge.de/statistics">
            AuthType Basic
            AuthName "Domainstatistiken"
            AuthUserFile "/var/www/vhosts/system/oooledge.de/pd/d..httpdocs@plesk-stat"
            require valid-user
        </Directory>

        Alias /error_docs /var/www/vhosts/oooledge.de/error_docs
        ErrorDocument 400 /error_docs/bad_request.html
        ErrorDocument 401 /error_docs/unauthorized.html
        ErrorDocument 403 /error_docs/forbidden.html
        ErrorDocument 404 /error_docs/not_found.html
        ErrorDocument 500 /error_docs/internal_server_error.html
        ErrorDocument 405 /error_docs/method_not_allowed.html
        ErrorDocument 406 /error_docs/not_acceptable.html
        ErrorDocument 407 /error_docs/proxy_authentication_required.html
        ErrorDocument 412 /error_docs/precondition_failed.html
        ErrorDocument 414 /error_docs/request_uri_too_long.html
        ErrorDocument 415 /error_docs/unsupported_media_type.html
        ErrorDocument 501 /error_docs/not_implemented.html
        ErrorDocument 502 /error_docs/bad_gateway.html
        ErrorDocument 503 /error_docs/maintenance.html

        IncludeOptional "/opt/psa/admin/conf/file_sharing.conf*"

        IncludeOptional "/var/www/vhosts/system/oooledge.de/conf/siteapp.d/*.conf"

        DirectoryIndex "index.html" "index.cgi" "index.pl" "index.php" "index.xhtml" "index.htm" "index.shtml"

        Include "/var/www/vhosts/system/oooledge.de/conf/vhost_ssl.conf"

        <Directory /var/www/vhosts/oooledge.de>
            AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,SymLinksIfOwnerMatch,MultiViews,FollowSymLinks,ExecCGI,Includes,IncludesNOEXEC
        </Directory>

        <IfModule mod_headers.c>
        </IfModule>

        #extension letsencrypt begin
        Alias /.well-known/acme-challenge "/var/www/vhosts/default/htdocs/.well-known/acme-challenge"

        <Location /.well-known/acme-challenge/>
            # Require all granted
            Order Deny,Allow
            Allow from all
            Satisfy any
        </Location>

        <LocationMatch "^/.well-known/acme-challenge/(.*/|)\.">
            # Require all denied
            Order Allow,Deny
            Deny from all
        </LocationMatch>
        #extension letsencrypt end
    </VirtualHost>

</IfModule>

<VirtualHost 91.250.115.48:80 >
    ServerName "oooledge.de:80"
    ServerAlias "www.oooledge.de"
    ServerAlias "ipv4.oooledge.de"
    UseCanonicalName Off

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]
    </IfModule>
</VirtualHost>

and my iipsrv.conf (included together with httpd.conf)

<IfModule mod_headers.c>
#Header set BASE_URL "https://oooledge.de/"
</IfModule>

# Create a directory for the iipsrv binary
ScriptAlias /fcgi-bin/ "/var/www/fcgi-bin/"

# Set the options on that directory
<Directory "/var/www/vhosts/fcgi-bin">
   AllowOverride None
   Options None
  # Syntax for access is different in Apache 2.4 - uncomment appropriate version
  # Apache 2.2
  #   Order allow,deny
  #   Allow from all

  # Apache 2.4
  Require all granted

  # Set the module handler
  AddHandler fcgid-script .fcgi
</Directory>

# Set our environment variables for the IIP server
FcgidInitialEnv VERBOSITY "5"
FcgidInitialEnv LOGFILE "/var/www/vhosts/oooledge.de/logs/iipsrv.log"
FcgidInitialEnv MAX_IMAGE_CACHE_SIZE "10"
FcgidInitialEnv JPEG_QUALITY "50"
FcgidInitialEnv MAX_CVT "3000"
#FcgidInitialEnv BASE_URL "/var/www/vhosts/oooledge.de/httpdocs"

# Define the idle timeout as unlimited and the number of # processes we want
FcgidIdleTimeout 0
FcgidMaxProcessesPerClass 1
#FcgidBusyTimeout 600
#FcgidIOTimeout 600
#FcgidConnectTimeout 600

permission on /var/www/fcgi-bin/iipsrv.fcgi

-rwxr-xr-x 1 root root 6238368 Aug 15 12:52 iipsrv.fcgi

apache modules

 access_compat_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 core_module (static)
 dav_fs_module (shared)
 dav_lock_module (shared)
 dav_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 fcgid_module (shared)
 filter_module (shared)
 headers_module (shared)
 http_module (static)
 include_module (shared)
Loaded Modules:
 log_config_module (static)
 logio_module (static)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 perl_module (shared)
 proxy_fcgi_module (shared)
 proxy_module (shared)
 python_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 socache_shmcb_module (shared)
 so_module (static)
 ssl_module (shared)
 status_module (shared)
 suexec_module (shared)
 unixd_module (static)
 userdir_module (shared)
 version_module (static)
 watchdog_module (static)

The Console Output by accessing a side, using the IIPImage Server says:

Request to access cookie or storage on “https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.8/fontfaceobserver.js” was blocked because we are blocking all third-party storage access requests and content blocking is enabled.  
Request to access cookie or storage on “https://91.250.115.48/fcgi-bin/iipsrv.fcgi?IIIF=/var/www/vho…/6fc3a3383f93b67653e39d938f661ccf.jpg/full/55,/0/default.jpg” was blocked because we are blocking all third-party storage access requests and content blocking is enabled.  
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://91.250.115.48/fcgi-bin/iipsrv.fcgi?IIIF=/var/www/vho…sski_original/f1ec174f5a432be36edba208076f03a8.jpg/info.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).  
Source-Map-Fehler: request failed with status 404
Ressourcen-Adresse: https://oooledge.de/libraries/mirador/build/mirador/mirador.js?pwa674
Source-Map-Adresse: openseadragon.js.map

There are several reasons I can imagine why it's not working:

1) I can reach the server over the IP-adress:
https://91.250.115.48/fcgi-bin/iipsrv.fcgi
, but get an internal error 500 by trying the domain path:
https://oooledge.de/fcgi-bin/iipsrv.fcgi

Maybe it has to do something with the base_urls or with the IP to Domain resolving.

2) docroot and suexec
Because the suexec.log mentioned the docroot, I've tried to find out my docroot for suexec, but

suexec -V 

didn't work (suexec: command not found)

I have installed the suexec-custom package (suexec -V still do not work) and I have a /etc/apache2/suexec/www-data file with this content:

/var/www/cgi-bin
/var/www
/var/www/fcgi-bin

# The first two lines contain the suexec document root and the suexec userdir
# suffix. If one of them is disabled by prepending a # character, suexec will
# refuse the corresponding type of request.
# This config file is only used by the apache2-suexec-custom package. See the
# suexec man page included in the package for more details.

3) Access-Control-Allow-Origin
Since the console output of https://oooledge.de/wisski_views/b719fd1ac3844863103c508912965b883443 says something about

I've tried the timeout stuff and so on mentioned in others posts, but I don't think it's a latency problem.
Thank you for your help!

Best Answer

The answer lies in the use of the Plesk enviroment. Plesk 17.8.11 have own configs for suexec and it is not possible to alter the settings - so the solution is to not use Plesk, if you want own suexec configs, docroot etc.