Score:0

Parse HTML as PHP on a Azure App Service (Linux) running PHP 8.1

in flag

I am really struggling to get an Azure App Service running Linux and PHP 8 or 8.1 to parse HTML files through PHP. The 8.0 and 8.1 versions run on nginx rather than Apache.

I have started by updating the nginx blocked used by the app service, located at /etc/nginx/sites-enabled/default, to read the below. This is as per default, except adding the HTML location alongside PHP:

server {
    listen 8080;
    listen [::]:8080;
    root /home/site/wwwroot;
    index  index.php index.html index.htm;
    server_name  example.com www.example.com;
    port_in_redirect off;

    location / {
        index  index.php index.html index.htm hostingstart.html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /html/;
    }

    location ~ [^/]\.(php|html)(/|$)  {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
        fastcgi_connect_timeout         300;
        fastcgi_send_timeout           3600;
        fastcgi_read_timeout           3600;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }
}

This correctly then attempts to parse HTML files through PHP, however they all then display the following error:

NOTICE: Access to the script '/home/site/wwwroot/login.html' has been denied (see security.limit_extensions)

I have then gone to /usr/local/etc/php-fpm.d/www.conf and added the following line:

security.limit_extensions = .php .php3 .php4 .php5 .php7 .html Normally, this would then work. Under an App Service however, I still receive the security.limit_extensions error message. Running php-fpm -tt appears to show the correct settings are in place and applied.

Other posts reference SeLinux, which doesn't appear to be running, and cgi.fix_pathinfo which is set to 1.

I am aware the above files do not maintain on app services after a restart, but are currently in place.

Has anyone (Please!!) got this to work and successfully parsed HTML as PHP on PHP8.1, as an Azure App Service?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.