Skip to content

Commit

Permalink
Nginx config now includes app-specific config snippets.
Browse files Browse the repository at this point in the history
Closes iphoting#16.
  • Loading branch information
iphoting committed Feb 17, 2013
1 parent 92e8084 commit abc9f12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Create a `conf/` directory in the root of the your deployment. Any files with na

This way, you can customise settings specific to your application, especially the document root in `nginx.conf.erb`. (Note the .erb extension.)

Alternatively, the bundled `nginx.conf.erb` will automatically include all nginx configuration snippets within the application directory: `conf/nginx.d/*.conf`. This is another way that you can modify the `root` and `index` directives. Further, if the config snippets end with `.erb`, they will be parsed and have `.conf` extension appended to its filename.

Pre-compiling binaries
----------------------
Expand Down
9 changes: 9 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ echo "Booting nginx"
# Override config files if provided in app.
if [ -d /app/conf ]; then
mkdir -p /app/conf/nginx.d
if [ -d /app/conf/etc.d ]; then
cp -f /app/conf/etc.d/* /app/vendor/php/etc.d/
fi
Expand All @@ -245,6 +247,13 @@ fi
# Set correct port variable.
erb /app/vendor/nginx/conf/nginx.conf.erb > /app/vendor/nginx/conf/nginx.conf
# Parse .erb into .conf.
for f in /app/conf/nginx.d/*.erb
do
erb "\${f}" > "\${f}.conf"
done
# Set NEWRELIC key
if [ -x "/app/local/bin/newrelic-license" ]; then
/app/local/bin/newrelic-license
Expand Down
8 changes: 5 additions & 3 deletions conf/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ http {
server unix:/tmp/php-fpm.socket;
}

root /app/;
index index.php index.html index.htm;

server {
listen <%= ENV['PORT'] %>;
server_name _;

root /app/;
index index.php index.html index.htm;

# Some basic cache-control for static files to be sent to the browser
location ~* \.(?:ico|css|js|gif|jpeg|jpg|png)$ {
expires max;
Expand Down Expand Up @@ -97,6 +97,8 @@ http {
# # }
#}

include /app/conf/nginx.d/*.conf

location ~ .*\.php$ {
try_files $uri =404;
limit_conn phplimit 5; # limit to 5 concurrent users to PHP per IP.
Expand Down

0 comments on commit abc9f12

Please sign in to comment.