Dokku静态站点自定义nginx配置

Dokku static site custom nginx config

我有一个超级简单的网站,我一直在使用 Dokku 作为静态网站。

我最近意识到 dokku static buildpack 上 nginx 的默认配置使所有文件都可以通过 uri 访问。我想将其范围缩小到我需要为页面提供服务的文件。

我已经创建了一个自定义 app-nginx.conf.sigil 文件(见下文),但它似乎在构建时被 dokku 忽略了。

网站上的所有文件仍然可用,并且 dokku 构建输出中有两行让我觉得我的 nginx 配置有问题:

仅供参考 - 应用名称已替换为 <app-name>

$> git push dokku master
Counting objects: 3, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 305 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Cleaning up...
-----> Building <app-name> from herokuish...
-----> Adding BUILD_ENV to build environment...
-----> .static app detected
-----> Copy static files to www
-----> Reusing nginx binary from cache
-----> Using user provided app-nginx.conf.sigil
-----> Using default app-nginx.conf.sigil
-----> Using default mime.types
-----> Discovering process types
       Default types for  -> web
-----> Releasing <app-name> (dokku/<app-name>:latest)...
-----> Deploying <app-name> (dokku/<app-name>:latest)...
-----> Attempting to run scripts.dokku.predeploy from app.json (if defined)
-----> App Procfile file found (/home/dokku/<app-name>/DOKKU_PROCFILE)
-----> DOKKU_SCALE file found (/home/dokku/<app-name>/DOKKU_SCALE)
=====> web=1
-----> Attempting pre-flight checks
       For more efficient zero downtime deployments, create a file CHECKS.
       See http://dokku.viewdocs.io/dokku/deployment/zero-downtime-deploys/ for examples
       CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
-----> Default container check successful!
-----> Running post-deploy
-----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)
-----> Found previous container(s) (139a82449b6c) named <app-name>.web.1
=====> renaming container (139a82449b6c) <app-name>.web.1 to <app-name>.web.1.1485630818
=====> renaming container (37e990b5d729) mad_nobel to <app-name>.web.1
-----> Configuring <app-name>...(using built-in template)
-----> Creating https nginx.conf
-----> Running nginx-pre-reload
       Reloading nginx
-----> Setting config vars
       DOKKU_APP_RESTORE: 1
-----> Shutting down old containers in 60 seconds
=====> 139a82449b6c2642efb3a2f5706de93a2012003518461619ffdb37681c195906
=====> Application deployed:
       http://<app-name>
       https://<app-name>

To dokku@<app-name>:<app-name>
   f49a26d..90acc86  master -> master

麻烦的台词当然是:

-----> Using user provided app-nginx.conf.sigil
-----> Using default app-nginx.conf.sigil

还有我的 app-nginx.conf.sigil 文件:

worker_processes 1;
error_log stderr;
pid nginx.pid;
daemon off;

events {
  worker_connections 768;
}

http {
  types_hash_max_size 2048;
  include mime.types;
  server {
    listen {{ $.PORT }};
    server_name  _;
    {{ if ne $.NGINX_ROOT "" }}
      root /app/www/{{ $.NGINX_ROOT }};
    {{ else }}
      root /app/www;
    {{ end }}
    index index.html;

    location / {
      try_files /index.html /favicon.ico /logo.png;
    }

    location /css/ {
      try_files $uri;
    }
  }
}

关于如何完成我正在尝试做的事情有什么想法(限制服务器只提供我想要的文件)?

谢谢!

已通过更新 Dokku 解决 - 该问题隐藏在以前的版本中。绝对由 Dokku 0.8.0 解决。