Launching Kirby on Azure Web Service

Hey!
Currently having the task to migrate Kirby from on-prem to Azure Web Service.
So far so good!
After launching the starter kit as a first test i am facing the first issues :smile:
After changing a few settings i kind of got the website to load.
But(!): Only the html part loads and not the css scripts as https is required.


I cant load the css because of the https.
Any ideas to fix this issue ?
Error message (cant post second picture because im a new user):

Mixed Content: The page at 'https://***.azurewebsites.net/' was loaded over HTTPS, but requested an insecure script 'http://example.com:8080/assets/js/prism.js'. This request has been blocked; the content must be served over HTTPS.

The same error is thrown with the css scripts :slight_smile:

Changing ā€œHTTPS Requiredā€ setting to ā€œfalseā€ doesent solve the issue for me. Thank you!

Hello :slight_smile:

did you replace that part in the error with this or does the error literally say requested an insecure script 'http://example.com:8080/assets/js/prism.js'?

Never used kirby :face_with_diagonal_mouth:
So no havent changed it!

No, I mean here on the forum :sweat_smile:
Did you replace your real domain name with example.com or was it written exactly like that in the error message?

Yes, was exactly written like that in the error! :smile:

Out of curiosity Iā€™ve just created a free Azure PHP App Service following the Quickstart guideā€¦ And the problem seems to be that it automatically sets these variables:

Kirby relies on those to generate any absolute URL. example.com and port 8080 are both, obviously, wrong.
I donā€™t know how one could correct these.

There have been recent changes (like literally in the latest 3.7.1 version that was released a few days ago) to how proxy servers are detected by kirby. So I donā€™t reliably know what the best way forward would be. Maybe @lukasbestle knows more details.

Something you could do (and someone more versed with Azure App Services should check this) would be giving Kirby explicitly the exact server name and protocol, by adapting your index.php from the starterkit to this:

<?php

require __DIR__ . '/kirby/bootstrap.php';

echo (new Kirby([
    'server' => [
        'SERVER_NAME' => $_SERVER['HTTP_DISGUISED_HOST'],
        'HTTPS' => $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'
    ]
]))->render();
1 Like

Actuallyā€¦ It seems like the PHP quicktstart thing from azure runs on nginx. Therefore the standard .htaccess file is ignored and one must find a way to configure nginx to rewrite the requests like apache with mod_rewrite would do.
Hereā€™s a guide on how to configure nginx: Running Kirby on a Nginx web server | Kirby CMS - but I donā€™t know how one would reach the config file from the azure platform

1 Like

You can reach the config file via ssh (scrolling down on the left side)
I am absolutly not familiar with this, but i am goint to try! If i have success i am going to post here!
@Rasteiner! Thanks for your support if you have any additional info please let me know :slight_smile:

Then thereā€™s Configure PHP apps - Azure App Service | Microsoft Learn that states:

The default PHP image for App Service uses Apache

But Iā€™m getting error messages like these:
image
And those donā€™t look like apache.


found the config file under /etc/nginx/sites-enabled/default:

server {
    #proxy_cache cache;
        #proxy_cache_valid 200 1s;
    listen 8080;
    listen [::]:8080;
    root /home/site/wwwroot;
    index  index.php index.html index.htm;
    server_name  example.com www.example.com; 

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

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /html/;
    }
    
    # Disable .git directory
    location ~ /\.git {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Add locations of phpmyadmin here.
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        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;
    }
}

(hello there ā€œexample.comā€, btw)

On the other hand the shell warns you that everything outside of /home is not persisted (I guess that is the only folder that is mounted into the docker container). So, I donā€™t know how you would load a config, since that would require restarting nginx, which would stop the container, which would discard your changes to the config :confused:

1 Like

[solution] kind of :slight_smile:
You are right! You cant modify the nginx config directly, but indirectly!

Move the nginx config in the home directory:

cp /etc/nginx/sites-available/default /home/site/nginx.conf

Now modify the file:

vi /home/site/nginx.conf

Configure now website etc.

Now create a startup script:

vi /home/site/startup.sh

Content of that file:

cp /home/site/nginx.conf /etc/nginx/sites-available/default
service nginx reload

Now save & exit:
Under App Properties you can configure a startup command:

/home/site/startup.sh

Done! Reload the website! Tho the content still doesent load, at least the url is correct :slight_smile:

As the URL Bug is fixed, i am going to open a new ticket for the not loading css und js files