• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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: 14
  • php_settings.png
    php_settings.png
    49.1 KB · Views: 11
  • postman_cacll.png
    postman_cacll.png
    14.3 KB · Views: 11
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