Plesk: passing the authorization headers in PHP when running with FastCGI/mod_fcgid

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, December 10, 2011

Follow me on Twitter as @mattiasgeniar

When you try to pass authorization headers via PHP to provide a login interface, you’ll notice it doesn’t work when running it with FastCGI enabled in Plesk by default. It does work with the standard mod_php Apache module for PHP.

The solution is to add the following directive to your Apache configuration in Plesk. Add this to the /var/www/vhosts/[DOMAIN]/conf/vhost.conf file.

FcgidPassHeader     Authorization

And run the Plesk Reconfigurator so it knows to include that vhost.conf file in the Apache configs.

# /usr/local/psa/admin/bin/websrvmng -av

Test your config:

# service httpd configtest

Syntax error on line 7 of /var/www/vhosts/[DOMAIN]/conf/vhost.conf:

Invalid command ‘FcgidPassHeader’, perhaps misspelled or defined by a module not included in the server configuration

But that doesn’t work. That’s because Plesk starts with its own implementation of the FastCGI and not the “normal” one.

rpm -qa | grep ‘fcgid’

psa-mod_fcgid-1.10-3

The solution is as simple as installing the regular mod_fcgid to replace it.

# yum install mod_fcgid

And your list should look similar to this.

# rpm -qa | grep fcgid

psa-mod_fcgid-1.10-3

mod_fcgid-2.3.5-2.el5.art

And the configtest will now work.

# service httpd configtest

Syntax OK

The extra FastCGI parameter is now being included as it should and will pass along the Authorization headers via PHP.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.