This a crate to install and run nginx via Pallet. This crate is heavily based off of Hugo Duncans nginx-crate. The main differences with this one being...
- The crate is updated to work with Pallet 0.8.
- The crate has been modified to use a much more recent version of nginx.
- The crate's configurations are much more data driven.
- The crate no longer supports passenger (and is something that will hopefully be supported in the future once the ruby crates are modified for 0.8.0).
- Please see the ReleaseNotes.md for more information regarding the releases and changes.
- You MAY need to make sure you have updated your packages before running the install phase.
- Tested on Ubuntu
- Tested on Centos 6.3+
- It expects the site file to have a .site extension. There is an enhancement that is entered to make this more flexible.
The settings expose A LOT of variables. They can be divided into the terms nginx conf and nginx site configuration.
Settings should work absolute fine across nginx conf and nginx site configuration when using the ::download
install-strategy. This is also the preferred strategy.
If you want to use the package based nginx install, then please note only the nginx site configuration settings should be modified.
The nginx crate uses the following settings:
:install-strategy
(:packages
:package-source
::download
). Default is ::download
Please see nginx.clj for more details on what the settings map can contain.
Artifacts are released released to Clojars. If you are using Maven, add the following definition to your pom.xml
:
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
With Leiningen
[org.clojars.strad/nginx-crate "0.8.6"]
With Maven
<dependency>
<groupId>org.clojars.strad</groupId>
<artifactId>nginx-crate</artifactId>
<version>0.8.6</version>
</dependency>
The nginx crate defines the nginx function, that takes a settings map and returns a default server-spec for
installing nginx. You can use this in a group-spec
or server-spec
. The phases defined are
settings
, install
, configure
, run
, stop
, restart
. The configure phase is where you can modify
the upstream blocks and other configuration files.
(group-spec "my-node-with-nginx"
:extends [(pallet.crate.nginx/nginx {})])
For instance the below could be passed in as settings. It will enable the default.site. It basically creates a reverse proxy for http and https connections to a server. I use this configuration for httpkit.
(def http-server-config
{:sites [{:action :enable
;; Notice the .site file extension. See the README notes section for more information.
:name "default.site"
:upstreams [{:lines [{:server "127.0.0.1:8080"}
{:keepalive 32}]
:name "http_backend"}]
:servers [
{:access-log ["/var/log/nginx/app.access.log"]
:locations [{:path "/"
:proxy-pass "http://http_backend"
:proxy-http-version "1.1"
:proxy-set-header [{:Connection "\"\""},
{:X-Forwarded-For
"$proxy_add_x_forwarded_for"},
{:Host "$http_host"}]}]}
{:listen "443"
:ssl "on"
:ssl_certificate "/etc/ssl/certs/myssl.crt"
:ssl_certificate_key "/etc/ssl/private/myssl.key"
:keepalive_timeout "70"
:locations [{:path "/"
:proxy-pass "http://http_backend"
:proxy-http-version "1.1"
:proxy-set-header [{:Connection "\"\""},
{:X-Forwarded-For
"$proxy_add_x_forwarded_for"},
{:Host "$http_host"}]}]}]}]})
Please enter bugs into the GitHub issues db. I will try to fix what I can when I can. Remember pull requests are welcomed :).
Licensed under EPL
Copyright 2010, 2011, 2012, 2013 Hugo Duncan.