Biar lebih mudah, saya rangkum aja ya jadi beberapa poin. Pertama, info apa saja yang saya gunakan di aplikasi kali ini:
-
Di sini saya menggunakan setup docker dari akun resmi git nya Akaunting.
-
Menggunakan cara sesuai dengan README nya.
-
Menggunakan nginx sebagai reverse proxy
-
Menggunakan certbot Let’s Encrypt sebagai penyedia sertifikat.
Kedua. Beberapa masalah apa yang saya dapatkan:
-
Https nya ga jalan, semua asset/resource masih menggunakan http. sehingga pas buka browser, buka login page berantakan.
-
Setelah melakukan
# php artisan vendor:publish --provider="Fideloper\Proxy\TrustedProxyServiceProvider"
& menghilangkan komen pada proxies di config/trustedproxy.php, malah jadi mix content blocking (ada konten http & https di aplikasi)
- Di dokumentasi reverse proxy nya si Akunting, ga ada contoh config buat nginx, cuma ada buat Apache.
Ketiga, solusi dari masalah di poin kedua:
-
Untuk masalah pertama kita bisa lakukan sesuai penjelesan Wu Wu Jian di forum Akaunting
a. Go into the akaunting container,
docker exec -it acct_akaunting_1 bash
b. Publish TrustedProxy package,
php artisan vendor:publish --provider="Fideloper\Proxy\TrustedProxyServiceProvider"
c. Edit config/trustedproxy.php file (in my case, the full path is /var/www/akaunting/config/trustedproxy.php). Since ‘vi’ or ’nano’ is not available in the docker container, I used ‘sed’ command to modify the ‘proxy’ line.
cat config/trustedproxy.php | sed "s/# 'proxies' => '\*'/'proxies' => '*'/" > /tmp/trustedproxy.php
d. Ensure that the changes made is correct:
diff config/trustedproxy.php /tmp
e. Replace the trustedproxy.php file with the modified one,
mv /tmp/trustedproxy.php config
-
Penyelesaian untuk masalah nomor 2 dan 3 di atas. Gampang saja, menambahkan
proxy_set_header X-Forwarded-Proto: https;
pada config nginx nya. Berikut config yang saya gunakan di aplikasi saya
location / {
#prevent search engine indexing
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options nosniff;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#you can set X-Forwarded-Proto: https. But I prefer using $scheme
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_pass http://127.0.0.1:8080;
keepalive_timeout 30s;
proxy_read_timeout 1800;
proxy_connect_timeout 10;
proxy_send_timeout 10;
# allow the server to close connection on non responding client, this will free up memory
reset_timedout_connection on;
# request timed out -- default 60
client_body_timeout 10;
# if client stop responding, free up memory -- default 60
send_timeout 2;
}

Jika kamu merasa tulisan ini bermanfaat & membantu kamu, kamu bisa berdonasi lewat saweria
If you feel this website help you, you can donate at saweria