Git Product home page Git Product logo

nginx-buildpack's Introduction

DEPRECIATED

This buildpack has been depreciated in favour of the more up to date (and better named) https://github.com/cloudfoundry-community/staticfile-buildpack. Please use that instead.


A buildpack for hosting static HTML websites on Cloud Foundry using Nginx

Using this buildpack as-is

Ensure that your app's root folder has an index.html or index.htm or Default.htm file (which will be served as the default page).

Run:

cf push --buildpack https://github.com/cloudfoundry-community/nginx-buildpack.git

Custom configuration files

You can customise the configuration by adding a nginx.conf to your root folder.

If the buildpack detects this file it will be used in place of the built-in nginx.conf, and run through the same erb processor. An example of the most basic nginx.conf (this is the one included in the build pack's conf directory):

worker_processes 1;
daemon off;

error_log <%= ENV["APP_ROOT"] %>/nginx/logs/error.log;
events { worker_connections 1024; }

http {
  log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent';
  access_log <%= ENV["APP_ROOT"] %>/nginx/logs/access.log cloudfoundry;
  default_type application/octet-stream;
  include mime.types;
  sendfile on;
  gzip on;
  tcp_nopush on;
  keepalive_timeout 30;

  server {
    listen <%= ENV["PORT"] %>;
    server_name localhost;

    location ~ /\.ht { deny  all; }
    location / {
      root <%= ENV["APP_ROOT"] %>/public;
      index index.html index.htm Default.htm;
    }
  }
}

Building the nginx package

Vagrant was used for building nginx with the latest pcre (8.33 at time of writing)

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "ubuntu-server-10.04"
  config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
  config.vm.synced_folder "/your/home/dir", "/nginx"
end

Build script

#!/bin/sh
# http://jamie.curle.io/blog/compiling-nginx-ubuntu/

pcre_version=8.33
nginx_version=1.5.10

apt-get install -fy build-essential zlib1g-dev

mkdir ~/src
cd ~/src

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$pcre_version.tar.gz
tar -xzvf pcre-$pcre_version.tar.gz
cd pcre-$pcre_version/
./configure # /usr/local is the default so no need to prefix
make
make install
ldconfig # this is important otherwise nginx will compile but fail to load

cd ~/src
wget http://nginx.org/download/nginx-$nginx_version.tar.gz
tar -xvzf nginx-$nginx_version.tar.gz 
cd nginx-$nginx_version
./configure

make 
make install

cd /usr/local
sudo tar -zcvpf /nginx/nginx-$nginx_version.tar.gz nginx/

nginx-buildpack's People

Contributors

andypiper avatar envygeeks avatar ihuston avatar mrdavidlaing avatar soudmaijer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx-buildpack's Issues

Applications fail to stage/run

Push fails, app flaps:

$ cf push --buildpack https://github.com/cloudfoundry-community/nginx-buildpack.git
Name> andyp-static-web

Save configuration?> n

Uploading andyp-static-web... OK
Stopping andyp-static-web... OK

Preparing to start andyp-static-web... OK
-----> Downloaded app package (8.0K)
-----> Downloaded app buildpack cache (4.0K)
Initialized empty Git repository in /tmp/buildpacks/nginx-buildpack.git/.git/
-----> Doing work with nginx-1.4.1 son.
-----> Uploading droplet (944K)
Checking status of app 'andyp-static-web'...
  0 of 1 instances running (1 down)
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 flapping)
Push unsuccessful.

Logs indicate broken paths?

$ cf logs andyp-static-web
Getting logs for andyp-static-web #0... OK

Reading logs/env.log... OK
TMPDIR=/home/vcap/tmp
VCAP_APP_PORT=63160
VCAP_CONSOLE_IP=0.0.0.0
USER=vcap
VCAP_APPLICATION={"application_users":[],"instance_id":"b0e3715f15dc6405a8a106eb8b016dbb","instance_index":0,"application_version":"c1c7352b-cd00-404d-83bb-5d09d17519b9","application_name":"andyp-static-web","application_uris":["apstatic.cfapps.io"],"started_at":"2013-07-31 15:52:09 +0000","started_at_timestamp":1375285929,"host":"0.0.0.0","port":63160,"limits":{"mem":256,"disk":1024,"fds":16384},"version":"c1c7352b-cd00-404d-83bb-5d09d17519b9","name":"andyp-static-web","uris":["apstatic.cfapps.io"],"users":[],"start":"2013-07-31 15:52:09 +0000","state_timestamp":1375285929}
PATH=/bin:/usr/bin
PWD=/home/vcap
VCAP_SERVICES={}
HOME=/home/vcap/app
SHLVL=2
PORT=63160
VCAP_APP_HOST=0.0.0.0
MEMORY_LIMIT=256m
VCAP_CONSOLE_PORT=63161
_=/usr/bin/env



Reading logs/staging_task.log... OK
-----> Downloaded app package (8.0K)
-----> Downloaded app buildpack cache (4.0K)
Initialized empty Git repository in /tmp/buildpacks/nginx-buildpack.git/.git/
-----> Doing work with nginx-1.4.1 son.



Reading logs/stderr.log... OK
mv: cannot stat `/app/app/nginx/conf/nginx.conf': No such file or directory
boot.sh: 23: cannot create /app/app/nginx/conf/nginx.conf: Directory nonexistent
exec: 28: /app/app/nginx/sbin/nginx: not found
tail: cannot open `/app/app/nginx/logs/*.log' for reading: No such file or directory
tail: no files remaining



Reading logs/stdout.log... OK

nginx 1.5.10 missing modules

Since latest updated build of nginx, the realip_module we're require is missing.

It looks like all buildflags from last one weren't used in the current build:

buildpack_nginx_build_flags=(
  --with-http_gzip_static_module
  --with-http_realip_module
  --without-mail_pop3_module
  --without-mail_imap_module
  --without-mail_smtp_module
  --without-http_ssi_module
  --without-http_userid_module
  --without-http_auth_basic_module
  --without-http_split_clients_module
  --without-http_fastcgi_module
  --without-http_uwsgi_module
  --without-http_scgi_module
  --without-http_memcached_module
  --without-http_limit_conn_module
  --without-http_limit_req_module
  --without-http_empty_gif_module
  --prefix=/app/nginx
  --with-pcre=./pcre-$buildpack_pcre_version
)

Did you build by using support/heroku-buildpack or from a custom script?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.