• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

Question Empty Authorization header on PHP with nginx

nicojmb

New Pleskian
Hi,

I'm developing a PHP RestAPI server with JWT and Bearer Auth.

In my client side (postman) send the header authorization but in PHP the variable $_SERVER['HTTP_AUTHORIZATION'] is empty.

Here is my plesk configuration is (details in attaached images):

  • Hosting Settings: PHP 7.4.11 - FPM served by nginx


¿How get this headers with nginx in my php code?
 

Attachments

  • hosting_settings.png
    hosting_settings.png
    60 KB · Views: 17
  • php_settings.png
    php_settings.png
    49.1 KB · Views: 14
  • postman_cacll.png
    postman_cacll.png
    14.3 KB · Views: 14
I think that in this case you need to add two directives to Nginx like

Code:
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
I have not tested this, but think this should work in the "Directivas adicionales de nginx" field.
 
I think that in this case you need to add two directives to Nginx like

Code:
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
I have not tested this, but think this should work in the "Directivas adicionales de nginx" field.

Hi, added this directives but do not work, the $_SERVER['HTTP_AUTHORIZATION'] still empty.

1603889747125.png
 
Hi, i don´t know whay, but if i add this apache directive works:

Apache config:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

i thought apache parameters are not used when nginx proxy is enabled
 
Nginx "proxy" means that Nginx serves static files while it forwards all other requests to Apache. .htaccess and other Apache settings are used by Apache as always, just not on static files that are served by Nginx.
 
Hi, i don´t know whay, but if i add this apache directive works:

Apache config:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

i thought apache parameters are not used when nginx proxy is enabled
Hi nicojmb,
Could you explain more details about the steps about how you did it?
Did you follow this?
 
Hi nicojmb,
Could you explain more details about the steps about how you did it?
Did you follow this?

Hi,

Add at top of .htaccess this line:

Apache config:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
 
Back
Top