├── Dockerfile ├── LICENSE ├── README.md └── config ├── laravel ├── nginx-start.sh └── nginx.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | MAINTAINER "Dylan Lindgren" 4 | 5 | WORKDIR /tmp 6 | 7 | # Install Nginx 8 | RUN apt-get update -y && \ 9 | apt-get install -y nginx 10 | 11 | # Apply Nginx configuration 12 | ADD config/nginx.conf /opt/etc/nginx.conf 13 | ADD config/laravel /etc/nginx/sites-available/laravel 14 | RUN ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/laravel && \ 15 | rm /etc/nginx/sites-enabled/default 16 | 17 | # Nginx startup script 18 | ADD config/nginx-start.sh /opt/bin/nginx-start.sh 19 | RUN chmod u=rwx /opt/bin/nginx-start.sh 20 | 21 | RUN mkdir -p /data 22 | VOLUME ["/data"] 23 | 24 | # PORTS 25 | EXPOSE 80 26 | EXPOSE 443 27 | 28 | WORKDIR /opt/bin 29 | ENTRYPOINT ["/opt/bin/nginx-start.sh"] 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Dylan Lindgren 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Docker + Laravel](https://cloud.githubusercontent.com/assets/6241518/4891729/359014b8-63ab-11e4-8f48-c6e69c3ee948.jpg) 2 | 3 | This is a [Docker](http://www.docker.com) image for [Nginx](http://nginx.org), intended for use in the fashion described on my series of blog articles about using Docker and the [Laravel PHP framework](http://www.laravel.com) together: 4 | 5 | 1. [Docker for the Laravel framework](http://dylanlindgren.com/docker-for-the-laravel-framework/) (24 Sep 2014) 6 | 2. [Beautiful Laravel Development with Docker & Fig](http://dylanlindgren.com/laravel-development-docker-fig/) (9 Oct 2014) 7 | 8 | An automated build for this repo is available on the [Docker Hub](https://registry.hub.docker.com/u/dylanlindgren/docker-laravel-nginx/). 9 | 10 | This image works well with the below related images. 11 | - [dylanlindgren/docker-laravel-data](https://github.com/dylanlindgren/docker-laravel-data) 12 | - [dylanlindgren/docker-laravel-phpfpm](https://github.com/dylanlindgren/docker-laravel-phpfpm) 13 | - [dylanlindgren/docker-laravel-composer](https://github.com/dylanlindgren/docker-laravel-composer) 14 | - [dylanlindgren/docker-laravel-artisan](https://github.com/dylanlindgren/docker-laravel-artisan) 15 | - [dylanlindgren/docker-laravel-bower](https://github.com/dylanlindgren/docker-laravel-bower) 16 | - [dylanlindgren/docker-laravel-phpunit](https://github.com/dylanlindgren/docker-laravel-phpunit) 17 | 18 | If you have any feedback or questions, feel free to leave a comment on my blog, or you can contact me on Twitter with [@dylanlindgren](https://twitter.com/dylanlindgren) or email with dylan.lindgren@gmail.com. 19 | -------------------------------------------------------------------------------- /config/laravel: -------------------------------------------------------------------------------- 1 | server { 2 | client_max_body_size 20M; 3 | listen 80 default_server; 4 | 5 | root /data/www/public; 6 | index index.php index.html index.htm; 7 | 8 | location / { 9 | try_files $uri $uri/ /index.html /index.php?$query_string; 10 | } 11 | 12 | location ~ \.php$ { 13 | include fastcgi.conf; 14 | fastcgi_pass phpfpm_backend; 15 | fastcgi_param SCRIPT_FILENAME $request_filename; 16 | } 17 | 18 | location ~ /\.ht { 19 | deny all; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /config/nginx-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cp /opt/etc/nginx.conf /etc/nginx/nginx.conf 3 | sed -i "s/%fpm-ip%/$FPM_PORT_9000_TCP_ADDR/" /etc/nginx/nginx.conf 4 | exec /usr/sbin/nginx 5 | -------------------------------------------------------------------------------- /config/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes 4; 3 | pid /run/nginx.pid; 4 | daemon off; 5 | 6 | events { 7 | worker_connections 768; 8 | # multi_accept on; 9 | } 10 | 11 | http { 12 | 13 | upstream phpfpm_backend { 14 | server %fpm-ip%:9000; 15 | } 16 | 17 | ## 18 | # Basic Settings 19 | ## 20 | 21 | sendfile off; 22 | tcp_nopush on; 23 | tcp_nodelay on; 24 | keepalive_timeout 65; 25 | types_hash_max_size 2048; 26 | # server_tokens off; 27 | 28 | 29 | # server_names_hash_bucket_size 64; 30 | # server_name_in_redirect off; 31 | 32 | include /etc/nginx/mime.types; 33 | default_type application/octet-stream; 34 | 35 | ## 36 | # Logging Settings 37 | ## 38 | 39 | access_log /data/logs/access.log; 40 | error_log /data/logs/error.log warn; 41 | 42 | ## 43 | # Gzip Settings 44 | ## 45 | 46 | gzip on; 47 | gzip_disable "msie6"; 48 | 49 | # gzip_vary on; 50 | # gzip_proxied any; 51 | # gzip_comp_level 6; 52 | # gzip_buffers 16 8k; 53 | # gzip_http_version 1.1; 54 | # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 55 | 56 | ## 57 | # nginx-naxsi config 58 | ## 59 | # Uncomment it if you installed nginx-naxsi 60 | ## 61 | 62 | #include /etc/nginx/naxsi_core.rules; 63 | 64 | ## 65 | # nginx-passenger config 66 | ## 67 | # Uncomment it if you installed nginx-passenger 68 | ## 69 | 70 | #passenger_root /usr; 71 | #passenger_ruby /usr/bin/ruby; 72 | 73 | ## 74 | # Virtual Host Configs 75 | ## 76 | 77 | include /etc/nginx/conf.d/*.conf; 78 | include /etc/nginx/sites-enabled/*; 79 | } 80 | --------------------------------------------------------------------------------