Nginx to server static files?

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/nginx.sample.conf at main · discourse/discourse · GitHub in production?
Thanks.

1 Like

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.