Masalah “Mixed Content” Semasa Install Akaunting Software dalam CentOS 7

Masa nak install software Akaunting ini ada satu masalah yang mana dapat error “Mixed Content”. Error log ini cuma boleh nampak bila enable Developer mode dekat browser dan pilih Console tab. Bila load page, untuk kes aku sebab first time installation jadi masa dia load page itu nampak error mixed content ini.

Mixed Content: The page was loaded over HTTPS, but requested an insecure script
Console tab

Untuk kes aku dan orang yang lain yang dapat error yang sama, benda ini jadi bila guna reverse proxy dan Akaunting software tak boleh handle session dari reverse proxy atau load balancer atau apa-apa middle layer application.

Sebenarnya Akaunting dah lepaskan fix dah beberapa tahun lepas cuma aku rasa yang guide / knowledge based dia akan berterabur jadi susah orang nak linked dengan solution dia. Issue yang user ini create yang baru aku jumpe solution untuk masalah ini. Jadi aku cuma ikut sahaja artikel yang Akaunting dah buat di sini;

https://akaunting.com/docs/developer-manual/reverse-proxy

Dekat dalam server just execute command dekat bawah sebab, kalau new installation, file trustedproxy.php tak wujud dalam directory config.

[root@webblog html]# php artisan vendor:publish --provider="Fideloper\Proxy\TrustedProxyServiceProvider"
Copied File [/vendor/fideloper/proxy/config/trustedproxy.php] To [/config/trustedproxy.php]
Publishing complete.
[root@webblog html]#

Ok bila dah generate kita verify file itu created dan buat sikit modifikasi dekat file trustedproxy.php

[root@webblog config]# vi trustedproxy.php
[root@webblog config]# ls
api.php           charts.php          dompdf.php       hashing.php     laratrust.php              mediable.php  search-string.php  trustedproxy.php           view.php
app.php           columnsortable.php  enlightn.php     ide-helper.php  laravel-model-caching.php  menu.php      services.php       trustedproxy.php_20210810
auth.php          cors.php            excel.php        imagecache.php  livewire.php               module.php    session.php        type.php
broadcasting.php  database.php        filesystems.php  image.php       logging.php                money.php     setting.php        update.php
cache.php         debugbar.php        firewall.php     language.php    mail.php                   queue.php     stats.php          version.php
[root@webblog config]# vi trustedproxy.php
[root@webblog config]#

Content dia macam dekat bawah yang aku cuma allow adalah localhost / 127.0.0.1 sahaja, aku tak nak dia dengar request dari tempat lain.

[root@webblog config]# cat trustedproxy.php
<?php

return [

    /*
     * Set trusted proxy IP addresses.
     *
     * Both IPv4 and IPv6 addresses are
     * supported, along with CIDR notation.
     *
     * The "*" character is syntactic sugar
     * within TrustedProxy to trust any proxy
     * that connects directly to your server,
     * a requirement when you cannot know the address
     * of your proxy (e.g. if using ELB or similar).
     *
     */
    'proxies' => ['127.0.0.1'],

    /*

Siap dah ini dan boleh reload balik page Akaunting tadi. Aku sarankan pakai incognito mode lepas dah modify config file tadi.

Leave a Comment