question

YoussefCHTOUROU-5548 avatar image
0 Votes"
YoussefCHTOUROU-5548 asked ryanchill commented

Handle Authorization Header in IIS

I would migrate from Azure Web App Linux (PHP application , apache server ) to Azure Windows App Service (IIS) and i 'am confused about handling authorization header in IIS

In .htaccess , i simply putting these lignes , and the Application work fine.

    # Handle Authorization Header
    # RewriteCond %{HTTP:Authorization} .
    # RewriteRule .* - [E=Authorization:%{HTTP:Authorization}]

I try to import these rules in hosted IIS server, but it's look IIS unable to convert them.

So can someone can help me?

Regards.




azure-webappswindows-server-iis
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It is widely reported that Microsoft moved away from supporting PHP on Windows, https://betanews.com/2020/07/11/microsoft-drops-php-support/ So it is rather strange to see you try to migrate from Linux to Windows. What for?

1 Vote 1 ·

Sorry , in Linux , i faced a performance problem : my application is more fast in Windows.

0 Votes 0 ·

also , if Microsoft forget PHP , why PHP Slack is existing in Azure web app Slack ?

0 Votes 0 ·
ryanchill avatar image
0 Votes"
ryanchill answered ryanchill commented

If I'm not mistaken, that rewrite rule is setting the authorization value to the Authorization header should a value exists. I don't think you will need that @YoussefCHTOUROU-5548. I personally haven't seen where IIS strips the authorization header from the request. I would see if your application still works as expected without this rewrite condition. If you do happen to run into an error, please comment down below with the error you're seeing, how your application is setup, and the client making the request.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your reply :

  • When i use .htaccess, and i comment these lignes :

    RewriteCond %{HTTP:Authorization} .

    RewriteRule .* - [E=Authorization:%{HTTP:Authorization}]



my application show 401 unauthorized in some API , so when i move to IIS , i think i should import all rules from .htaccess to web.config used by IIS





0 Votes 0 ·
ryanchill avatar image ryanchill YoussefCHTOUROU-5548 ·

Hi @YoussefCHTOUROU-5548, what I was intending is the rewrite rule sets the Authorization header in the HTTP request. You shouldn't need this rule. Is your PHP app able to run as is without this rewrite rule in place?

0 Votes 0 ·
SamWu-MSFT avatar image
0 Votes"
SamWu-MSFT answered ryanchill commented

Hi @YoussefCHTOUROU-5548

You can refer to this link about how translate .htaccess Content to IIS web.config.

Translate .htaccess Content to IIS web.config.


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for you reply

i already check this link from Microsoft documentation, but my application still not working and also , my rewrite rule cann't be imported by IIS import rules

can you help me please ?

0 Votes 0 ·
ryanchill avatar image ryanchill YoussefCHTOUROU-5548 ·

No it can't be imported into your app service @YoussefCHTOUROU-5548 but you can create a web.config file on your app service like this sample, just translate what you need from your .htaccess following the link @SamWu-MSFT provided. However, just as I said earlier, I don't believe you'll need that rewrite rule to run your app.

0 Votes 0 ·