当前位置: 动力学知识库 > 问答 > 编程问答 >

Dokku static site custom nginx config

问题描述:

I have a super-simple website that I've been serving as a static site with Dokku.

I recently realized that the default configuration for nginx on the dokku static buildpack makes all files available via a uri. I'd like to scope this down to just the files I need to serve the page.

I've created a custom app-nginx.conf.sigil file (see below), but it appears to be ignored by dokku on build.

All files are still available on the site and there are two lines in the dokku build output that make me think there is something wrong with my nginx config:

FYI - the app name has been replaced with <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 [email protected]<app-name>:<app-name>

f49a26d..90acc86 master -> master

The troublesome lines are of course:

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

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

And my app-nginx.conf.sigil file:

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;

}

}

}

Any thoughts on how to accomplish what I'm trying to do (restrict the server to only serve files I want it to)?

Thanks!

分享给朋友:
您可能感兴趣的文章:
随机阅读: