[Solved] fcgi and css
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
ig · 2022-02-14 09:33
Hi,
I've setup a snall fcgi application using nginx on freebsd. The
application runs fine, the hmtl is rendered and data is available from
the server. The application is build, just using fpc-web with
webmodules.
However when adding ccs style sheet information, then this html page
is
rendered using CSS when the style sheet is defined locally using .
The style sheet is located in the same folder as the html page.
However when changing the href to e.g. then the page
is rendered with the CSS.
Anyone an idea why the local css sheet is not picked up?
rgds,
ig
----------------------------------------------------------------------
ig · 2022-02-14 13:56
Found the solution by adding a location into the server section
pointing to the css folder. So nginx configuration is now:
server {
listen 8080;
listen [::]:8080;
server_name caw.local.be;
root /var/www/;
location /fcgi/ {
gzip off;
fastcgi_split_path_info ^(/fcgi/)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9210;
}
location /css/ {
root /var/www;
}
}
Or is there a better way of doing this?
----------------------------------------------------------------------
Leledumbo · 2022-02-18 04:01
Quote from: ig on February 14, 2022, 02:56:29 pmOr is there a better
way of doing this?
No, it IS the better way. An alternative would be for your fcgi app to
serve the CSS, but that takes a toll on its ability to serve requests.
Because unlike Nginx that's been fully prepared to serve static
contents, and can return proper cache headers, fpweb with its
RegisterFileLocation is not. You will have to do that on your own. So,
not only performance, but also code complexity is worse.
The BEST way, however, is to offload the serving to a 3rd party
caching service like CloudFlare.