• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

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