Answer the question
In order to leave comments, you need to log in
Who is better to entrust the processing of statics, expressJS or Nginx?
Hello.
Actually this is the question.
Statics in expressJS:
var theme = 'MyTheme';
app.use(express.static(path.join(__dirname, 'themes', theme, 'public')));
location ~* \.(jpg|jpeg|gif|ico|png|css|js|xml|rss|txt|svg|eot|ttf|woff|woff2)$ {
root /home/example.com/themes/??????????/public;
access_log off;
autoindex off;
expires 30d;
}
Answer the question
In order to leave comments, you need to log in
Yes, no one ever leaves express hanging around on the web. They always proxy through nginx, and giving statics as a backend is generally nonsense.
The static is given through the CDN, and express, which is sticking out with a bare ass, which is hiding behind a sticking out nginx, is only suitable for prototyping.
Making a symlink to an active topic
How to install nodejs
https://nodejs.org/en/download/package-manager/#de...
How to set up nginx <-> nodejs
https://www.digitalocean.com/community/tutorials/h...
White people solve this problem in this way. The backend (in your case, expressJS) generates links to statics in such a way that they contain an indication of the topic, for example /static/my_theme/css/style.css
. In the nginx config it is written something like this:
location /static/ {
root /home/example.com/static/;
access_log off;
autoindex off;
expires 30d;
}
/home/example.com/static/
only public files are in the folder, all JavaScript should be in other folders. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question