Nginx להגשת קבצים סטטיים?

סיכום מבוסס בינה מלאכותית

The discussion revolves around whether it makes sense to use an external Nginx server to serve static files for Discourse. valsha asks about configuring Nginx to handle static assets like /assets, /user_avatar, and /uploads with caching headers, noting they are using Nginx outside the container and referencing the official Discourse installation guide. pfaffman questions the need for this setup, suggesting it’s unnecessary, hard to maintain, and offers little benefit, especially since a reverse proxy is already in use. valsha clarifies that the external Nginx is needed because other sites run on the same server, making direct serving of Discourse static files a practical necessity.

Hi, Does it make sense to serve static files using nginx?
Something like:

 location ~ ^/assets/(?<asset_path>.+)$ {
      expires 1M;
      add_header Cache-Control "max-age=2629746, public";
    }
location ~ ^/user_avatar/(?<user_avatar_path>.+)$ {
      expires 1M;
      add_header Cache-Control "max-age=2629746, public";
    }
location ~ ^/uploads/(?<uploads_path>.+)$ {
      expires 1M;
      add_header Cache-Control "max-age=2629746, public";
    }

We are use nginx outside the container. Thank you.

I guess you didn’t follow How to install Discourse in production?

@pfaffman
I am using your guide to almost the fullest extent.
Except for the part concerning nginx
my app.yml

  #  - "templates/web.ssl.template.yml"
  #  - "templates/web.letsencrypt.ssl.template.yml"
  #  - "80:80"   # http
  #  - "443:443" # https

Can i use your discourse/config/nginx.sample.conf at main · discourse/discourse · GitHub in production?
Thanks.

I don’t think that there is any reaon to have the external NGINX serve those files directly. I think that you can, but it’ll be hard to configure, hard to maintain, and provide virtually no benefit. If you thought that it would make things faster, why would you use a reverse proxy at all?

@pfaffman
I am using it this way because there are other sites running on this server, not just discourse.