CSS / Images not loading on new domains
Added by tgiles almost 16 years ago
Hi, All.
I'm using lighttpd-1.4.19 on Ubuntu 8.04.2 configured for several (8) vhost domains. Two of my domains I have mod_evasive enabled to keep them from eating up all of my bandwidth.
I setup a new domain and went to configure Wordpress on it. It was then I noticed that none of the images, nor any CSS was loading. The pages come up ok, just no images or CSS. Verified my other domains still has CSS and images loading ok... Just the new one having issues.
I triple-checked my new domain's configuration file and feel confident there's nothing dodgy about the configuration.
I disabled mod_evasive and restarted lighty and got the same issue. As a test, I moved the Wordpress installer directory to where one of my working domains was and the installer loaded just fine- images, etc. was perfect.
On the same server I configured Apache on port 81, pointed it to the relevant directory, and all the images and CSS loaded without any issues. So, the problem seems to be with lighty itself.
Honestly, I'm stumped. I see no errors in any system logs, nor in the logs which lighty create.
Any thoughts on why this is happening on my new domain? The configuration file is pretty basic since I'm still getting used to using lighty full time.
Thanks in advance for any input or troubleshooting advice you may have.
tom
Replies (3)
RE: CSS / Images not loading on new domains - Added by JJ almost 16 years ago
I'm having a similar problem. I can't seem to get the link tag to include a basic CSS file. This is making me nuts. The same code in a PHP file works fine in Apache, but Lighttpd just seems to ignore it. If anyone has a suggestion I'd appreciate hearing it.
Thanks,
JJ
RE: CSS / Images not loading on new domains - Added by JJ almost 16 years ago
Ok, nitrox provided some great feedback on lighttpd IRC channel that helped me find the issue. My link statement to include the CSS file had a href that looked like this:
href="/css/main.css"
My lighttpd root was the htdocs folder, but the file trying to include the main.css was in a sub folder. Since lighttpd begins with the doc-root to include CSS files from the link tag it was trying to find the relative path or physical path relative to the htdocs, not the sub folder. I changed my href to look like this:
href="/myfolder/css/main.css"
and it worked like a champ. I think this behavior is inconsistent with what Apache and IIS tend to do so that's what was throwing me a curve ball.
I hope this helps you out.
RE: CSS / Images not loading on new domains - Added by tgiles almost 16 years ago
Thanks for the input, JJ. I finally came across the issue and was able to resolve it. Documenting it here just in case someone else stumbles across the thread.
I have eight domains. Most are subdomains of my main domain (I.E. foo.example.com, bar.example.com). There's a few other domains, but none of them load images or .css files.
One of my domains is an image site. A while back I added in a configuration item to the config to block image hotlinking. The configuration ended up looking something like this:
$HTTP["host"] =~ "image\.example\.com" {
server.document-root = "/vhosts/image.example.com"
accesslog.filename = "/vhosts/logs/image.example.com.access.log"
connection.kbytes-per-second = 15
evasive.max-conns-per-ip = 2
}
$HTTP["referer"] !~ "^($|http?://(.*\.)?example\.com)" {
url.access-deny = (".jpg", ".gif", ".png", ".css", ".js")
}
So, everything worked perfectly until I tried to add a new domain in that had a completely different domain name in. What I learned is that if one leaves something like the hotlink protection outside of the "domain bracket", lighty will count it a global configuration item.
Since the new domain name was different from example.com, the referrer wasn't right and no images or .css files loaded. The new configuration below is the correct one and works perfectly now.
$HTTP["host"] =~ "image\.example\.com" {
server.document-root = "/vhosts/image.example.com"
accesslog.filename = "/vhosts/logs/image.example.com.access.log"
connection.kbytes-per-second = 15
evasive.max-conns-per-ip = 2
$HTTP["referer"] !~ "^($|http?://(.*\.)?example\.com)" {
url.access-deny = (".jpg", ".gif", ".png", ".css", ".js")
}
} # <-- curse you, damn bracket!
You'd think after all these years of PHP programming I'd eye those bracket's with a little more suspicion.
Anyway, issue resolved. Hope this helps someone.
Cheers,
tom