通过Nginx代理aiohttp服务器时,如何正确指定其他静态文件?

时间:2019-04-22 01:09:46

标签: nginx aiohttp

我有类似这样的东西,大致上(减去无关的html块包装器)直接来自aiohttp docs。

server {
 listen 8099;
 client_max_body_size 4G;


  location /static/* {
    # path for static files
    root /var/www/pkm/static/;
  }

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_redirect off;
    proxy_buffering off;
    proxy_pass http://aiohttp;
  }


}

现在,我所有的静态内容都位于/ var / www / pkm,但并非全部都位于static /子目录中。例如manifest.json和index.html都在顶层。

那么,要确保对/manifest.json和其他请求的请求不被代理到我的aiohttp,而是由nginx处理,该怎么办?我是否真的需要单独列出它们,还是应该确保要由该代理服务处理的内容具有一些前缀,例如/ api /?如果是这样,我想我会找到答案。将位置设置为/ api /或类似的位置。

正确吗?

在这种情况下,nginx提供index.html是最佳实践吗?

0 个答案:

没有答案