Hi everyone,
1. The problem I’m having:
I have Ubuntu server on LightSail with caddy trying to host my flask web app. Web app works fine, but the images are not loading at all. Images are there, I can see them in directory, and they are connected properly in HTML and CSS. I realized its a permission problem. I tried to change permission and ownership, maybe I did because I cant access directory at all. I tried chaging it again with command sudo chown -R caddy:caddy assets
it doenst do anyting. When i tried ls -l assets
it shows me this:
ls: cannot access 'assets/green.png': Permission denied
ls: cannot access 'assets/1.jpg': Permission denied
ls: cannot access 'assets/Logo.png': Permission denied
ls: cannot access 'assets/Untitled-1.jpg': Permission denied
ls: cannot access 'assets/restaurant-with-christmas-decorations-2022-11-15-18-02-21-utc.j
pg': Permission denied
ls: cannot access 'assets/background1.jpg': Permission denied
ls: cannot access 'assets/google_map_logo.png': Permission denied
ls: cannot access 'assets/banjaluka.jpg': Permission denied
ls: cannot access 'assets/LOGO_EPSwhite.png': Permission denied
ls: cannot access 'assets/LOGO_EPS.png': Permission denied
ls: cannot access 'assets/logopowered.png': Permission denied
ls: cannot access 'assets/URI.txt': Permission denied
ls: cannot access 'assets/logo1.png': Permission denied
ls: cannot access 'assets/Watercolor pian.jpg': Permission denied
ls: cannot access 'assets/kkl.jpg': Permission denied
ls: cannot access 'assets/2.jpg': Permission denied
ls: cannot access 'assets/Watercolor pian.png': Permission denied
ls: cannot access 'assets/google_map.png': Permission denied
total 0
-????????? ? ? ? ? ? 1.jpg
-????????? ? ? ? ? ? 2.jpg
-????????? ? ? ? ? ? LOGO_EPS.png
-????????? ? ? ? ? ? LOGO_EPSwhite.png
-????????? ? ? ? ? ? Logo.png
-????????? ? ? ? ? ? URI.txt
-????????? ? ? ? ? ? Untitled-1.jpg
-????????? ? ? ? ? ? 'Watercolor pian.jpg'
-????????? ? ? ? ? ? 'Watercolor pian.png'
-????????? ? ? ? ? ? background1.jpg
-????????? ? ? ? ? ? banjaluka.jpg
-????????? ? ? ? ? ? google_map.png
-????????? ? ? ? ? ? google_map_logo.png
-????????? ? ? ? ? ? green.png
-????????? ? ? ? ? ? kkl.jpg
-????????? ? ? ? ? ? logo1.png
-????????? ? ? ? ? ? logopowered.png
-????????? ? ? ? ? ? restaurant-with-christmas-decorations-2022-11-15-18-02-2
1-utc.jpg
If anyone wonder about user and group stuff, this is output of caddy id
uid=998(caddy) gid=999(caddy) groups=999(caddy),33(www-data)
I don’t have much knowledge about user and group because am new to all of this.
2. Error messages and/or full log output:
Here is output of journalctl -u caddy -n 50
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: NOTIFY_SOCKET=/run/systemd/notify
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: HOME=/var/lib/caddy
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: LOGNAME=caddy
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: USER=caddy
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: INVOCATION_ID=2df7836501f34be0b89b80af6acf0c83
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: JOURNAL_STREAM=8:26292
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: SYSTEMD_EXEC_PID=2445
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.395149,"msg":"using provided configuration","config_file":>
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3964388,"logger":"admin","msg":"admin endpoint started","a>
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"warn","ts":1695312321.3965304,"logger":"http.auto_https","msg":"server is listen>
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3967326,"logger":"http.log","msg":"server running","name":>
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3969228,"msg":"autosaved config (load with --resume flag)">
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3969712,"msg":"serving initial configuration"}
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3970883,"logger":"tls.cache.maintenance","msg":"started ba>
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3971097,"logger":"tls","msg":"cleaning storage unit","desc>
Sep 21 16:05:21 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312321.3971236,"logger":"tls","msg":"finished cleaning storage un>
Sep 21 16:05:21 ip-172-26-8-229 systemd[1]: Started Caddy.
Sep 21 16:05:28 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312328.299067,"logger":"admin.api","msg":"received request","meth>
Sep 21 16:05:28 ip-172-26-8-229 caddy[2445]: {"level":"warn","ts":1695312328.29927,"logger":"admin.api","msg":"exiting; byeee!! "}
Sep 21 16:05:28 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312328.2992837,"logger":"http","msg":"servers shutting down with >
Sep 21 16:05:28 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312328.2995238,"logger":"admin","msg":"stopped previous server",">
Sep 21 16:05:28 ip-172-26-8-229 caddy[2445]: {"level":"info","ts":1695312328.2995343,"logger":"admin.api","msg":"shutdown complete","ex>
Sep 21 16:05:28 ip-172-26-8-229 systemd[1]: caddy.service: Deactivated successfully.
Sep 21 16:13:47 ip-172-26-8-229 systemd[1]: Starting Caddy...
Sep 21 16:13:47 ip-172-26-8-229 caddy[2548]: caddy.HomeDir=/var/lib/caddy
Sep 21 16:13:47 ip-172-26-8-229 caddy[2548]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Sep 21 16:13:47 ip-172-26-8-229 caddy[2548]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Sep 21 16:13:47 ip-172-26-8-229 caddy[2548]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Sep 21 16:13:47 ip-172-26-8-229 caddy[2548]: caddy.Version=v2.7.4 h1:J8nisjdOxnYHXlorUKXY75Gr6iBfudfoGhrJ8t7/flI=
Sep 21 16:13:47 ip-172-26-8-229 caddy[2548]: runtime.GOOS=linux
Hope this helps because i dont understand a thing here 
3. Caddy version:
v2.7.4 h1:J8nisjdOxnYHXlorUKXY75Gr6iBfudfoGhrJ8t7/flI=
4. How I installed and ran Caddy:
a. System environment:
No LSB modules are available.
Distributor ID:Ubuntu
Description:Ubuntu 22.04.1 LTS
Release:22.04
Codename:jammy
b. Command:
Process of starting caddy:
source env/bin/activate
cd Turizam
caddy stop
sudo caddy start
python run.py
d. My complete Caddy config:
On previous post francislavoie told me that i dont really need file_server
and reverse_proxy
. I just copied file server dont know what does it even do
if it is ok to delete it i will.
exploresrpska.com {
root * /shop/static/assets
file_server
reverse_proxy localhost:50100
}
5. Links to relevant resources:
Heres link of tutorial that i followed, maybe helps, dont know.