Skip to content

Commit abc9f12

Browse files
committed
Nginx config now includes app-specific config snippets.
Closes #16.
1 parent 92e8084 commit abc9f12

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Create a `conf/` directory in the root of the your deployment. Any files with na
2828

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

31+
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.
3132

3233
Pre-compiling binaries
3334
----------------------

bin/compile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ echo "Booting nginx"
225225
# Override config files if provided in app.
226226
if [ -d /app/conf ]; then
227227
228+
mkdir -p /app/conf/nginx.d
229+
228230
if [ -d /app/conf/etc.d ]; then
229231
cp -f /app/conf/etc.d/* /app/vendor/php/etc.d/
230232
fi
@@ -245,6 +247,13 @@ fi
245247
246248
# Set correct port variable.
247249
erb /app/vendor/nginx/conf/nginx.conf.erb > /app/vendor/nginx/conf/nginx.conf
250+
251+
# Parse .erb into .conf.
252+
for f in /app/conf/nginx.d/*.erb
253+
do
254+
erb "\${f}" > "\${f}.conf"
255+
done
256+
248257
# Set NEWRELIC key
249258
if [ -x "/app/local/bin/newrelic-license" ]; then
250259
/app/local/bin/newrelic-license

conf/nginx.conf.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ http {
3030
server unix:/tmp/php-fpm.socket;
3131
}
3232

33+
root /app/;
34+
index index.php index.html index.htm;
35+
3336
server {
3437
listen <%= ENV['PORT'] %>;
3538
server_name _;
3639

37-
root /app/;
38-
index index.php index.html index.htm;
39-
4040
# Some basic cache-control for static files to be sent to the browser
4141
location ~* \.(?:ico|css|js|gif|jpeg|jpg|png)$ {
4242
expires max;
@@ -97,6 +97,8 @@ http {
9797
# # }
9898
#}
9999

100+
include /app/conf/nginx.d/*.conf
101+
100102
location ~ .*\.php$ {
101103
try_files $uri =404;
102104
limit_conn phplimit 5; # limit to 5 concurrent users to PHP per IP.

0 commit comments

Comments
 (0)